Skip to content

Instantly share code, notes, and snippets.

@kraigh
Created October 25, 2012 21:27
Show Gist options
  • Save kraigh/3955540 to your computer and use it in GitHub Desktop.
Save kraigh/3955540 to your computer and use it in GitHub Desktop.
Staff View PHP LName Sort
list($fname1, $lname1) = explode(' ', $row1->title , 2);
list($fname2, $lname2) = explode(' ', $row2->title , 2);
return(strcasecmp($lname1,$lname2));
@jasonfroderman
Copy link

$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)); }

@jasonfroderman
Copy link

$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