r8 my sort algorithm /tech/
i call it ubersoftsort
r8 my sort algorithm /tech/
i call it ubersoftsort
How do I sort negative numbers? :(
Add absolute value of minimum element to all, sort, subtract
pretty much a synchronous sleep sort
Mine's better:
def sorting(array):
return sorted(array)
def main():
array = [2, 3, -1, 1, 5, 4, 0, -2]
new_array = sorting(array)
print(new_array)
if __name__ == "__main__":
main()
Not OP but you're more of a faggot than OP.
here's my final version of ubersoftsort.
O(n*k) its the best algorithm out there right now.
i'm very proud of myself, it can even sort negative numbers.
>best algorithm out there right now
Not really. Most of the times k is going to be close to n which leads to O(n^2).
heapsort best sort
>2016
>not using sleepsort
Are you all Pajeets or what?
>using python 2.x when python 3.x is a thing
Just looking at it, I think this has a bug.
Nice sleepsort you retard
No, it's just sleepsort
Comparing it to randomized quicksort you use 2 times more memory, and is only faster if the range of values is smaler than log(list size) wich is rare in a real world scenario.
i should probably be comparing it to counting or radix sort but im not remembering them very well atm.
That's nothing, rate THIS
>Displaying tabs as arrows
>Javascript
>Write once shitty code
cancer/10.
>no spacing anywhere
kys yourself
>while true
Fucking kill yourself
That's going to be a really inefficient sort if there is a huge difference between the largest and smallest items.
For example:
item = [2, 3, 1, 9999999, 2, 7]
is going to take a crazy amount of time, relative to a more efficient algorithm.
I think you can optimize it by giving multidigit numbers a higher substraction.
>kill yourself yourself
>not in-place
>not stable
>not O(nlogn)
I rate 1/10. The 1 is only because it sorts.
Do you even know what being stable means?
import random
items = [2, 3, 1, 5, 2, 7]
sorted=False
while not sorted:
sorted=True
random.shuffle(items)
for i in range(len(items)-1):
if items[i]>items[i+1]:
sorted=False
break
print items
It works
And now I'm blind. Thanks user!
ARROWS