4 ms·
I wonder what are these occasional situations where you need a quick and dirty sort?
by lpapez 2y ago
I wonder what are these occasional situations where you need a quick and dirty sort?
- gus_massa 2y agoI had to change the order of the rows and columns of a matrix to force the diagonal to be ordered. One possibility was to use the sort function on the diagonal, somehow get the permutation, and then apply the permutation to all the rows and columns. How had can it be? There is a 50% chance of apply the permutation in the wrong direction, and other possible tricky details. Since the worst case was N=20, I used bubble sort that is as quick and dirty, but it's also obvious and well known.
- codr7 2y agoThere are plenty of standard libraries out there that leave a lot to wish for. Sometimes I'm writing my own language, trying to figure something else out and don't feel like being sidetracked. Sometimes predictable performance is more important than optimal. Let's just say there are plenty of reasons why someone might want to do that.