Logo

Programming-Idioms

History of Idiom 100 > diff from v8 to v9

Edit summary for version 9 by :
New Python implementation by user [benaryorg]

Version 8

2015-12-27, 16:36:21

Version 9

2015-12-27, 16:39:17

Idiom #100 Sort by a comparator

Sort elements of array-like collection items, using a comparator c.

Idiom #100 Sort by a comparator

Sort elements of array-like collection items, using a comparator c.

Code
lst = [7,4,3,1,2]
def c(a,b):
	return a-b
lst.sort(c)