What is the Python sorted function? An example of how to use it.

0

The Python sort function is very straight-forward. The easiest way to think about this is the various ways you can sort files on your computer. Either by name, date, size, etc. This is essentially what Python sorted function is.

A few examples and then I’ll link you to a more complex Gist with a deep learning example.

Simple version:
In: sorted([5, 2, 3, 1, 4])
Out: [1, 2, 3, 4, 5]

Another version:
In: a = [5, 2, 3, 1, 4]
In: a.sort()
In: a
Out: [1, 2, 3, 4, 5]

Line 8 in the gist below show you how to sort files for a Deep Learning exercise looking at images and tensors.

https://gist.github.com/craine/5e917fe1144d2e163a71280ebfa07550

LEAVE A REPLY

Please enter your comment!
Please enter your name here