sorting - Emulate Lightroom list order with PHP -
i emulate same way lightroom orders list, using php. have tried number of different methods, still can't copy order exactly. here examples:
lightroom ordered (the way want order list): abcd fgh abcd0 abcd1 abcd2 abcd3 abcd10 abcd11 abcd22 abcdefgh abcd'fgh abcd-fgh tests: php: sort($line_list, sort_natural); natcasesort($line_list); abcd'fgh abcd-fgh abcd0 abcd1 abcd2 abcd3 abcd10 abcd11 abcd22 abcdefgh abcd fgh php: asort($line_list); abcd fgh abcd'fgh abcd-fgh abcd0 abcd1 abcd10 abcd11 abcd2 abcd22 abcd3 abcdefgh php: sort($line_list, sort_flag_case); abcd fgh abcd'fgh abcd-fgh abcd0 abcd1 abcd10 abcd11 abcd2 abcd22 abcd3 abcdefgh php: sort($line_list, sort_string); abcd fgh abcd'fgh abcd-fgh abcd0 abcd1 abcd10 abcd11 abcd2 abcd22 abcd3 abcdefgh php: sort($line_list, sort_numeric); abcd3 abcdefgh abcd'fgh abcd-fgh abcd22 abcd2 abcd0 abcd1 abcd10 abcd11 abcd fgh
is there way copy lightroom ordering?
<?php // comparison function function mysortingfunction($a, $b) { if ($a == $b) { return 0; } return ($a < $b) ? -1 : 1; } // array sorted $array = array('a' => 4, 'b' => 8, 'c' => -1, 'd' => -9, 'e' => 2, 'f' => 5, 'g' => 3, 'h' => -4); print_r($array); // sort , print resulting array uasort($array, 'mysortingfunction'); print_r($array); ?>
using example, have create own sorting function.
Comments
Post a Comment