Logo

Programming-Idioms

History of Idiom 100 > diff from v10 to v11

Edit summary for version 11 by :
New PHP implementation by user [Flyingmana]

Version 10

2015-12-27, 16:44:27

Version 11

2015-12-27, 17:10:13

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
$list = [7,4,3,1,2];
$c = function($a, $b){return $a-$b;}
usort($list, $c);

var_dump($list);