Forum

Thread tagged as: Question, Problem

Sorting on Unique ID (possible bug?)

I have a sidebar which displays links to anchors on the current page, sorted descending by their unique id:

$inPageLinks = perch_content_custom(array('Current Vacancies','Application Information','Recruitment Information'), array('template'=>'_sidebar-subnav.html','sort'=>'_id','sort-order'=>'DESC','skip-template'=>true,'return-html'=>true));

It works fine, ie the oldest items are at the bottom, until an item's _id hits 1000 which seems to start the sorting order again. For example:

<ul class="sidebar">
  <li data-id="999"><a href="#third">third</a></li>
  <li data-id="998"><a href="#second">second</a></li>
  <li data-id="997"><a href="#first">first</a></li>
  <li data-id="1001"><a href="#fifth">fifth</a></li>
  <li data-id="1000"><a href="#fourth">fourth</a></li>
</ul>

When it should be:

<ul class="sidebar">
  <li data-id="1001"><a href="#fifth">fifth</a></li>
  <li data-id="1000"><a href="#fourth">fourth</a></li>
  <li data-id="999"><a href="#third">third</a></li>
  <li data-id="998"><a href="#second">second</a></li>
  <li data-id="997"><a href="#first">first</a></li>
</ul>

I first noticed it on our live site but I can replicate it on our development site - happens in the exact same way. Not sure if it's something else causing the issue but all the templates seem like they should be working alright. Any help would be appreciated.

Alan Longstaff

Alan Longstaff 0 points

  • 6 years ago
Drew McLellan

Drew McLellan 2638 points
Perch Support

Try setting sort-type to numeric

Ah, works perfectly - for some reason I've never noticed the option to change sort-type before. My mistake! Thanks Drew