Sorting points

Let's talk about algorithms!

Moderator: Board moderators

Post Reply
New poster
Posts: 2
Joined: Fri Nov 12, 2004 8:41 pm

Sorting points

Post by marcink »

Could anybody tell me how to write an efficent algo for sorting points if we are given their coordinates?

Experienced poster
Posts: 105
Joined: Tue Oct 14, 2003 3:24 pm
Location: Utrecht, Holland

Post by Maniac »

Yes, define a relation between the points and just use quicksort or a garantueed N log N algorithm for sorting.

Experienced poster
Posts: 216
Joined: Tue Aug 31, 2004 1:02 am
Location: Tehran

Post by Moha »

define each point as a pair, because pair has < operator, and sorting it by sort function.

Post Reply

Return to “Algorithms”