Skip to content

Instantly share code, notes, and snippets.

@andfoy
Last active August 29, 2015 14:04
Show Gist options
  • Save andfoy/724eef1fb004848dc1c6 to your computer and use it in GitHub Desktop.
Save andfoy/724eef1fb004848dc1c6 to your computer and use it in GitHub Desktop.
import numpy as np
l = np.random.randint(0, 1000, 10).tolist()
b = {}
a = []
max = 0
for i in l:
if len(str(i)) > max:
max = len(str(i))
for i in range(0, max)[::-1]:
for n in l:
try:
b[int(str(n)[i]) = b[int(str(n)[i]) + [n]
except KeyError:
b[int(str(n)[i]) = [n]
except IndexError:
a.append(n)
l = []
[l.extend(j) for j in b.values()]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment