hello my question is, How do you sort a vector containing a bunch of game_object* 's ? You can use STD's algorithm.sort() somehow ... right ?
wwsoft
0
Light Poster
Recommended Answers
Jump to PostYes, but you'll have to overload the relational operators first. This is necessary so that they know how to compare elements of your class. Otherwise you will probably not get desirable results.
Jump to Posthow do you create one ?
Im trying to sort objects by their z
You might have something as simple as
// Compares two game objects by 'z' bool game_obj_compare(const game_obj * lhs, const game_obj * rhs) { return lhs->z < rhs->z; } // To sort a …
All 5 Replies
Fbody
682
Posting Maven
Featured Poster
vmanes
1,165
Posting Virtuoso
wwsoft
0
Light Poster
Fbody
682
Posting Maven
Featured Poster
mitrmkar
1,056
Posting Virtuoso
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.