We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
Just to clarify that lambda part, in case someone else doesn't understand how exactly string comparison works: '2' > '1' is True, but '2' > '10' is also True, as well as '2' > '1000'. That's why the strings are sorted by length first, because len('2') < len('10').
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Big Sorting
You are viewing a single comment's thread. Return to all comments →
Just to clarify that
lambda
part, in case someone else doesn't understand how exactly string comparison works:'2' > '1'
isTrue
, but'2' > '10'
is alsoTrue
, as well as'2' > '1000'
. That's why the strings are sorted by length first, becauselen('2') < len('10')
.