Last active
August 29, 2015 14:06
-
-
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
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
# 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