sorting in C++

Soldato
Joined
15 Feb 2011
Posts
10,234
Location
Slough
for my coursework i need to implement the convex hull algorithm in a GUI. part of this involves sorting a 2D array of co-ordinates by their X co-ordinate, but the lecturer has said that this is not an important thing and we should steal a sorting function from a library.

however, being a complete noob at programming i dont know which C++ library will have what i need, and if the sort will keep the X and Y co-ordinates together or not, so if someone could point me in the direction of the library and function i need it would be much appreciated :)

ps, dont be surprised if i come on here asking for help with a GUI, because we havent been taught how to do one
 
Look up STL algorithms, in particular std::sort. You'll have an STL implementation with your compiler. If you want a stable sort, there's a stable version IIRC.
 
Look up STL algorithms, in particular std::sort. You'll have an STL implementation with your compiler. If you want a stable sort, there's a stable version IIRC.

thanks, i'll take a look :)

am i right in thinking that the difference between a stable and unstable sort is that one switches equal values and the other doesnt (i forget which is which).
if thats the case then it shouldnt be a problem either way
 
thanks, i'll take a look :)

am i right in thinking that the difference between a stable and unstable sort is that one switches equal values and the other doesnt (i forget which is which).
if thats the case then it shouldnt be a problem either way

Stable sorting maintains the relative order of elements with the same value.
 
Back
Top Bottom