Skip to content

Commit a205014

Browse files
add comment
1 parent 7447e71 commit a205014

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

sort_lambda.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
int main(){
88
std::vector<std::string> myvec;
99
myvec = {"apple", "lemon", "orange", "banana", "onion", "melon", "durian"};
10+
//first sort by length(the longer the former), then by lexicographical order
1011
std::sort(myvec.begin(), myvec.end(),
1112
[](const std::string& a, const std::string& b) -> bool{return a.size() == b.size() ? a < b : a.size() > b.size();});
1213
std::copy(myvec.begin(), myvec.end(), std::ostream_iterator<std::string>(std::cout, " "));

0 commit comments

Comments
 (0)