Hi guys,
Is there a way I can use std::sort() to sort a 2D vector by the value of its first member?
So, for instance:
I can use std::sort(ProductKeyInfo.begin(), ProductKeyInfo.end()) which sorts by the indexes but can't work out how to sort by the alphabetic order of the strings for the fist member of each. So, i'd like to sort by ProductKeyInfo[i][0] Is there a simple way to do this?Code:std::vector< std::vector<char*> > ProductKeyInfo; ProductKeyInfo.push_back( vector<char*>() ); ProductKeyInfo[0].push_back( "Microsoft Windows" ); ProductKeyInfo[0].push_back( "DigitalProductId" ); ProductKeyInfo[0].push_back( "DecodeMicrosoftKey" ); ProductKeyInfo.push_back( vector<char*>() ); ProductKeyInfo[1].push_back( "Microsoft Office 2003 - Professional" ); ProductKeyInfo[1].push_back( "DigitalProductId" ); ProductKeyInfo[1].push_back( "DecodeMicrosoftKey" );
I guess I could write my own bubble sort method to do this, but I don't want to re-invent the wheel
Cheers guys!
Dave