Skip to content

Instantly share code, notes, and snippets.

@weirddan455
Created September 20, 2022 00:27
Show Gist options
  • Save weirddan455/b90b6496afa0811e05e619d823383ecf to your computer and use it in GitHub Desktop.
Save weirddan455/b90b6496afa0811e05e619d823383ecf to your computer and use it in GitHub Desktop.
from time import perf_counter_ns
array_size = 1000000
array = []
with open("unsorted.txt") as unsorted:
for i in range(array_size):
array.append(int(unsorted.readline()))
start = perf_counter_ns()
array.sort()
end = perf_counter_ns()
with open("sorted.txt", 'w') as sorted:
for i in range(array_size):
sorted.write(str(array[i]))
sorted.write('\n')
duration = (end - start) / 1000000.0
print("sort took " + str(duration) + "ms")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment