0

Am having a problem sorting a list of strings, by their lengths in descending order please help

14th Jan 2019, 7:45 AM
Ruth Ndichu
Ruth Ndichu - avatar
6 Réponses
+ 3
I tried your sample with states.sort(key = len) and it works, other than "Len" → "len" I didn't see any problem. P.S. I agree with Denise, you should've add the language (Python) on the post "Relevant Tags" section.
14th Jan 2019, 10:52 AM
Ipang
+ 1
Can you describe your problem? What have you tried? A list can sort your length, but you need to know which length belongs to which string.
14th Jan 2019, 9:17 AM
Denise Roßberg
Denise Roßberg - avatar
+ 1
Looks like python (you should tag your language) Maybe this example will help you: https://www.sololearn.com/learn/Python/2435/?ref=app
14th Jan 2019, 9:51 AM
Denise Roßberg
Denise Roßberg - avatar
0
@denise. this is an example I have states=["Nairobi", "Nakuru", " Mombasa", "Lamu"] I've been trying to use this sort function list.sort(key=Len)
14th Jan 2019, 9:35 AM
Ruth Ndichu
Ruth Ndichu - avatar
0
my apologies let me look at the link
14th Jan 2019, 10:54 AM
Ruth Ndichu
Ruth Ndichu - avatar
0
my apologies let me look at the link
14th Jan 2019, 10:54 AM
Ruth Ndichu
Ruth Ndichu - avatar