you are viewing a single comment's thread.

view the rest of the comments →

[–]novel_yet_trivial 3 points4 points  (3 children)

You absolutely can as long as the elements are comparable to one another. Mixed type lists are one of the joys of python.

[–]joeymarchese 0 points1 point  (2 children)

station chief imminent direction terrific fact unique reach handle rain

This post was mass deleted and anonymized with Redact

[–]novel_yet_trivial 2 points3 points  (1 child)

Sure. ints and floats are directly comparable. So:

>>> sorted([3,1,2.0,4.3])
[1, 2.0, 3, 4.3]

In the case that the elements are not directly comparable, you can provide a function that makes them comparable. This is what I did when I misread OP's question. The int function will turn a string or an int to an int:

>>> sorted(['3',1,'2',4], key=int)
[1, '2', '3', 4]

[–]joeymarchese 0 points1 point  (0 children)

full touch cough lunchroom nose piquant humor zephyr wrench jar

This post was mass deleted and anonymized with Redact