Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
Home » U++ Library support » U++ Core » How to sort a vector?
Re: How to sort a vector? [message #37844 is a reply to message #37842] Sat, 17 November 2012 00:34 Go to previous messageGo to previous message
koldo is currently offline  koldo
Messages: 3443
Registered: August 2008
Senior Veteran
Hello crydev

If MovieInfo has operator< it is easy, just call Sort(myvector);

If not, you can do this:

struct MySortWay {
	bool operator () (const MovieInfo& a, MovieInfo& b) const { 
		return a.value < b.value; // Just an example. It dependes on MovieInfo contents
	}
};

Vector <MovieInfo> myvector;

Sort(myvector, MySortWay);


Smile


Best regards
IƱaki
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Is libXi needed ??
Next Topic: To add serialize/xmlize/jsonize functions to EditField and others
Goto Forum:
  


Current Time: Tue Aug 26 22:20:06 CEST 2025

Total time taken to generate the page: 0.05583 seconds