Programming-Idioms

History of Idiom 28 > diff from v22 to v23

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

Version 22

Version 23

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)