News for hackers. Stuff that matters.
Re:Unconventional Sorting Algorithms by forinti on Thursday October 21, 2021 @01:27PM (#28947889)
My contribution: Power Sort.

Start with p=0 and add 2^n for each n. Then subtract the largest power of 2 successively to get your integers ordered.

Con: p will be very big.

Pro: you don't need ifs!

Re:Unconventional Sorting Algorithms by Paedor on Thursday October 21, 2021 @05:48PM (#28951233)
Fun fact, when you consider the bits required to contain p, this is equivalent to bucket sort with a bucket size of 1.
Re:Unconventional Sorting Algorithms by Snild on Thursday October 21, 2021 @02:17PM (#28948726)
Ooh, that's a fun one.

Another con: you'd better hope your input contains no duplicates. :)

Re:Unconventional Sorting Algorithms by dbaupp on Thursday October 21, 2021 @04:52PM (#28950697)
Duplicates could also be handled by using (L+1)^n, rather than 2^n, where L is the length of the input: even if all elements are identical one will end up with a unique value p = L * (L+1)^n.

For an efficient implementation, one might want to round L+1 up to the nearest power of 2 to get crucial micro-optimisations based on instructions for bit scanning.

(I think this ends up being a very complicated phrasing of a counting sort.)

Re:Unconventional Sorting Algorithms by forinti on Thursday October 21, 2021 @02:23PM (#28948817)
Easily solvable with a hash.

I have thought this through (I'm ashamed to admit).