Logo

Programming-Idioms

History of Idiom 28 > diff from v22 to v23

Edit summary for version 23 by :
New Lua implementation by user [jparoz]

Version 22

2015-12-22, 15:40:50

Version 23

2016-02-16, 17:07:55

Idiom #28 Sort by a property

Sort elements of array-like collection items in ascending order of x.p, where p is a field of type Item of the objects in items.

Idiom #28 Sort by a property

Sort elements of array-like collection items in ascending order of x.p, where p is a field of type Item of the objects in items.

Code
table.sort(items, function(a,b)
	if a.p < b.p then return true end
end)