PHP usort for string hierarchy
问题 I have a array with a string hierarchy like so: table, parent_table test, NULL test, NULL test2, test test4, NULL test5, test3 test6, test5 test3, test I want to sort with a function that goes something like this: usort($array, function($a,$b) { return ($a['table'] === $b['parent_table']) ? -1 : 1; }); Ideal result would be table, parent_table test, NULL test, NULL test2, test test3, test test5, test3 test6, test5 test4, NULL This would sort parents above children tables. I've been trying to