Last active
November 19, 2017 18:31
-
-
Save a-eid/1378bbf680cf0d715d41b53d2e02e7e8 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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