Skip to content

Instantly share code, notes, and snippets.

@a-eid
Last active November 19, 2017 18:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save a-eid/1378bbf680cf0d715d41b53d2e02e7e8 to your computer and use it in GitHub Desktop.
Save a-eid/1378bbf680cf0d715d41b53d2e02e7e8 to your computer and use it in GitHub Desktop.
import numbers
def numOrString(list):
cache = []
strings = []
nums = []
for n in list:
if(isinstance(n, numbers.Number)):
pass
cache.append(1)
nums.append(n)
else:
pass
cache.append(0)
strings.append(n)
return (cache , strings , nums,)
def main((cache , strings , nums)):
strings.sort()
strings.reverse()
nums.sort()
nums.reverse()
for i , c in enumerate(cache):
if c == 0:
cache[i] = strings.pop()
if c == 1:
cache[i] = nums.pop()
return cache
# how to call it
# main(numOrString( ["str" , 1 ,2,3 "asdf", ...] ))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment