Skip to content

Instantly share code, notes, and snippets.

@patrickmmartin
Last active August 29, 2015 14:06
Show Gist options
  • Save patrickmmartin/21763be701dd49595ddb to your computer and use it in GitHub Desktop.
Save patrickmmartin/21763be701dd49595ddb to your computer and use it in GitHub Desktop.
pads a list to get the alpha sort the same as the input array
# define the list of names
names = ["Benchmark Bills",
"Benchmark Bonds",
"Bills",
"Bonds",
"Agency",
"Sub-National",
"Corporate",
"Deposits"];
# go through the list, padding until the order is correct
i = len(names) - 1
while i > 0:
sorted_names = sorted(names)
while sorted_names.index(names[i]) < i:
for j in range (0, i):
names[j] = ' ' + names[j]
sorted_names = sorted(names)
i -= 1
print names
print sorted(names)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment