Answers for "sort strings by length and by alphabet"

C++
0

sort strings by length and by alphabet

bool comp(string a, string b) {
	if (a.size() != b.size()) return a.size() < b.size(); // primarily by length
	return a < b;  //secondarily by alphabetical
}
Posted by: Guest on April-12-2021

Code answers related to "sort strings by length and by alphabet"

Browse Popular Code Answers by Language