Why sort and sorted functions are showing different results?

Viewed 48

when I sort this list -> y = [20, 10 ,20]

y = sorted(y, key = y.count)
# y -> [10, 20, 20]

y.sort(key = y.count)
# y -> [20, 10, 20]

why do both functions give different results?

0 Answers
Related