I have a disturbing case : I would like to sort a list of strings with an associated weight, like that :
@array = [{0 => "string"}, {0 => "my string"}, {2 => "my very long string which I want to match"}]
The result of the sort should be:
{2 => "my very long string which I want to match"}
{0 => "my string"}
{0 => "string"}
The first element is the very long string because the difference pound/string.length has a better percentage as others.
I tried to sort by grouping by weight, and after by strings but it doesn’t work. I also tried to calculate ratios, but I’m still not getting the right ordered list.
Thanks a lot for your answers.
1 Answer