What is the more idiomatic way to sort a vector of strings by char?
Example:
Input:
["3r", "2n", "2s", "7r", "1s", "1s", "6r", "1s", "1n", "1n", "5n", "9n", "3r"]
Desired output:
["1n", "1n", "2n", "5n", "9n, "3r", "3r", "6r", "7r", "1s", "1s", "1s", "2s"]
首先,需要根据第二个字符对它们进行排序,以便将它们分组在一起,然后按第一个字符进行排序.
我用.filter
和.sort_by
试了很多方法,但都不成功.