Sign in to follow this  

Need an efficient sorting algorithm

Recommended Posts

So the first problem I see is that points in 2D don't have a well defined ordering to begin with. How do you want the points ordered? Sorted by X then Y, sorted by Y then X, sorted by the sum of X and Y, with respect to some space filling curve... etc.? Once you distill your comparison operator, then you can use any classical efficient sorting algorithm (something thats O(n lg n)). For example, merge sort is a fast, classical comparison based sorting algorithm that would be pretty easy to implement. You could find most of the necessary resources for mergesort anywhere on the web (the wikipedia page is a good place to start).


Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this