Created
February 5, 2009 16:07
-
-
Save jeremyBanks/58780 to your computer and use it in GitHub Desktop.
[2010-01] some shitty sort? don't remember what this was for.
This file contains hidden or 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
#!/usr/bin/env python | |
# encoding: utf-8 | |
from __future__ import division, with_statement | |
import sys | |
import random | |
def somesort(data): | |
"""A dumb n**2 sort.""" | |
data = list(data) | |
result = list() | |
while len(result) < len(data): | |
min_value = None | |
for index, value in enumerate(data): | |
if value is not None and (min_value is None or value < min_value): | |
min_index = index | |
min_value = value | |
result.append(min_value) | |
data[min_index] = None | |
return(result) | |
def main(*args): | |
data = [random.randint(0, 31) for n in range(16)] | |
print(data) | |
print(somesort(data)) | |
if __name__ == "__main__": sys.exit(main(*sys.argv[1:])) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment