Hacker Newsnew | past | comments | ask | show | jobs | submitlogin
Cyclesort - a curious little sorting algorithm (corte.si)
6 points by llambda on Jan 13, 2012 | hide | past | favorite | 1 comment


What am I missing? Author claims that if you know that you have as an input the permuted numbers 1..n you can "sort" them? Why would you have to "sort" them, why not just create the order?

    def quasiSort( a ):
        return range( 1, len( a ) + 1 )

    a = quasiSort( [ 3, 1, 2 ] )
    print a




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: