I have a list a = ['a1', 'b1', 'c1', 'd1', 'a2', 'b2', 'c2', 'd2',]
How can I get list b = ['a1,', 'a2', 'b1', 'b2', 'c1', 'c2', 'd1', 'd2']
without using .sorted()
?
Thanks!
listpython
I have a list a = ['a1', 'b1', 'c1', 'd1', 'a2', 'b2', 'c2', 'd2',]
How can I get list b = ['a1,', 'a2', 'b1', 'b2', 'c1', 'c2', 'd1', 'd2']
without using .sorted()
?
Thanks!
Best Answer
There is no
.sorted()
method for lists, though there is thesorted()
function, as S.Mark pointed out (which returns a new sorted list), and a.sort()
method (which sorts a list in place and returnsNone
). If you meant to not use thesorted()
function, then:otherwise, maybe you can clarify your question further.