Loading

Paste #pxkm81kif

  1. Index: src/station_gui.cpp
  2. ===================================================================
  3. --- src/station_gui.cpp (revision 27062)
  4. +++ src/station_gui.cpp (working copy)
  5. @@ -19,6 +19,7 @@
  6.  #include "cargotype.h"
  7.  #include "station_gui.h"
  8.  #include "strings_func.h"
  9. +#include "string_func.h"
  10.  #include "window_func.h"
  11.  #include "viewport_func.h"
  12.  #include "widgets/dropdown_func.h"
  13. @@ -222,7 +223,9 @@
  14.             GetString(buf_cache, STR_STATION_NAME, lastof(buf_cache));
  15.         }
  16.  
  17. -       return strcmp(buf, buf_cache);
  18. +       int r = strnatcmp(buf, buf_cache); // Sort by name (natural sorting).
  19. +       if (r == 0) return (*a)->index - (*b)->index;
  20. +       return r;
  21.     }
  22.  
  23.     /** Sort stations by their type */
  24. @@ -1186,7 +1189,7 @@
  25.     SetDParam(0, st2);
  26.     GetString(buf2, STR_STATION_NAME, lastof(buf2));
  27.  
  28. -   int res = strcmp(buf1, buf2);
  29. +   int res = strnatcmp(buf1, buf2); // Sort by name (natural sorting).
  30.     if (res == 0) {
  31.         return this->SortId(st1, st2);
  32.     } else {
  33.  

Comments