Jump to content
 

JimC

Members
  • Posts

    1,473
  • Joined

  • Last visited

Status Updates posted by JimC

  1. GWR Locomotive diagrams were numbered, in order, A-Z, A1-A999, B1-B999, so Z sorts before A1, A10 before A2 etc. PHP sort routines say "does not compute". I'm looking at creating a page of GWR locomotive diagrams and I'm damned if I want to code each addition by hand, I want a script to do it. So it looks as if I have to write a custom sort, which is a bit outside my comfort zone. Spit.

    1. truffy

      truffy

      Are you running this solely in PHP or pulling the data from SQL?

    2. JimC

      JimC

      Just in PHP. It wasn't too hard in the end: I just created a custom sort key:
       

      split the trailing number from the letter

      get the ascii value of the letter

      if string length > 1 char then

      index value = letter value *1000 plus trailing number

      else

      index value = letter value

       

      and sorted on that.

       

×
×
  • Create New...