Hameer Abbasi
Reputation
Top tag
Next privilege 125 Rep.
Vote down
 Apr 27 awarded Tumbleweed Nov 14 asked Generating a Nakagami Random Variable Aug 27 comment Sort an array in a specific order - not ascending/descending Marked as answer again for being closer to the exact algorithm. I didn't consider a self-balancing BST, or a `Balance()` function at all. Aug 27 accepted Sort an array in a specific order - not ascending/descending Aug 27 comment Sort an array in a specific order - not ascending/descending @Dukeling If the items of a are already sorted, then the BST formed will have a linear search time, and the overall algorithm will be O(n^2). Please correct me if I'm wrong. Aug 25 comment Sort an array in a specific order - not ascending/descending I might add that algorithms like this are exactly why I prefer to keep an array of indices rather than a sorted version of the array itself. Sadly, most programming languages don't have that facility while sorting. Aug 25 awarded Commentator Aug 25 comment Sort an array in a specific order - not ascending/descending True. His could be O(n^2) in the worst case, while yours would still be O(n log n). Marked yours as the answer fro being better in the worst case. Aug 24 comment Sort an array in a specific order - not ascending/descending @RalphChapin Forgive my ignorance, but can you explain or link to what you mean by "use w's unsort on a"? Aug 24 comment Sort an array in a specific order - not ascending/descending Both would be the same order since we're sorting numerically, first. Aug 24 awarded Scholar Aug 24 awarded Supporter Aug 24 comment Sort an array in a specific order - not ascending/descending +1 I don't think any kind of sorting algorithm has been made better than O(n log n). You just reduced my problem to that. Kudos! Marked yours as the answer for being the simplest here. Aug 12 revised Sort an array in a specific order - not ascending/descending Made clearer, the examples Aug 12 comment Sort an array in a specific order - not ascending/descending @DanPichelman I added those as per your request. Aug 12 revised Sort an array in a specific order - not ascending/descending Added missing commas Aug 12 comment Sort an array in a specific order - not ascending/descending @DanPichelman Compare only lets you do comparisons within the same array. @TMN Pick any one, doesn't really matter in my case. @user61852 I mean we exclude the first `i` elements of `w` on the `i`th iteration, but only the already sorted elements of `a` are excluded. Aug 12 revised Sort an array in a specific order - not ascending/descending added 35 characters in body Aug 12 asked Sort an array in a specific order - not ascending/descending Oct 31 awarded Editor