I am trying to take a std::vector<Card> and organize it by one of the int values stored inside the Card class. How could I go about doing this with iterators and the sort() method? Or is it not possible? Ty :)
MasterGberry
-3
Posting Whiz in Training
Recommended Answers
Jump to PostFirst, you'll have to create a < operator for your class and then you'll have to create a function that compares two objects of that class using the < operator and then call the sort algorithm
sort(your_vector.begin(), your_vector.end(), sort_function);
Here's a simple example
#include <iostream> …
All 3 Replies
gerard4143
371
Nearly a Posting Maven
mrnutty
761
Senior Poster
MasterGberry
-3
Posting Whiz in Training
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.