Sorting | Sololearn: Learn to code for FREE!

0

Sorting

how can we sort using second string in a set of list. list1=["willy","Cooper","Ram","hell"] out put should be based on second letter of each word i.e I, o, a, e list1=["Ram","hell","willy","Cooper"]

5/22/2018 10:12:03 PM

Kesava N

3 Answers

New Answer

+4

Write whatever sort you like and instead of comparing first > second use first[1:] > second[1:]. string[1:] creates a substring of the second character to the end.

+2

A sort must compare the strings. I'm telling you how to ignore the first character when you do your compare.

0

didn't get u. r u asking me to compare a string?