Created
October 25, 2012 21:27
-
-
Save kraigh/3955540 to your computer and use it in GitHub Desktop.
Staff View PHP LName Sort
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
list($fname1, $lname1) = explode(' ', $row1->title , 2); | |
list($fname2, $lname2) = explode(' ', $row2->title , 2); | |
return(strcasecmp($lname1,$lname2)); |
$sticky1 = true; // Stick referring to $row1
$sticky2 = false // Sticky referring to $row2
list($fname1, $lname1) = explode(' ', $row1->title , 2);
list($fname2, $lname2) = explode(' ', $row2->title , 2);
// $row1 = sticky so favor it
if ($sticky1 && !$sticky2) { return -1; }
// $row2 = sticky so favor it
else if (!sticky1 && $sticky2) { return 1; }
// Neither are so do normal sort
else { return(strcasecmp($lname1,$lname2)); }
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
$sticky1 = true; // Stick referring to $row1
$sticky2 = false // Sticky referring to $row2
list($fname1, $lname1) = explode(' ', $row1->title , 2);
list($fname2, $lname2) = explode(' ', $row2->title , 2);
// $row1 = sticky so favor it
if ($sticky1 && !$sticky2) { return -1; }
// $row2 = sticky so favor it
if (!sticky1 && $sticky2) { return 1; }
// Neither are so do normal sort
if (!sticky1 && !$sticky2) { return(strcasecmp($lname1,$lname2)); }