I have String data like "1,2,3,4,5,1,2,1,5,6". I split with "," and count them one by one. After that I want to order them with descending. How can I do that with Swift.
I want to get a result like this. Key should be the above string number(converting to Int is fine). Value should be number of data. If some data have the same count number, smaller key should be first.
final result
["1" => 3, "2" => 2, "5" => 2, "3" => 1, "4" => 1, "6" => 1]
or
[1 => 3, 2 => 2, 5 => 2, 3 => 1, 4 => 1, 6 => 1]