Level: 200
 

Sorting Items

In this article, I will describe the different possibilities for sorting items that exist in Sitecore.
This includes both manually sorting the items and different automatic sortings.

 

Written by: Jimmi Lyhne Andersen
Thu, Nov 5 2009

For this article I am using a fresh Sitecore 6.1 installation and I have created 4 items from the Sample Item template.

 

Screenshot of created sample items
 

By default these four sample items are sorted by their name. It is possible to sort these items manually by using the buttons in the Sorting group of the Home tab.

 

Screenshot of button for manual sorting
 

If you do this, Sitecore will insert a value in the Sortorder field in the Appearance section of the standard fields. Sitecore will set these values for all the siblings of the item you moved.

 

Screenshot of sortorder field
 
By this example we see that the items sortorder takes preference over the default sorting, which is sorting by name.
Sitecore has several other sortorders build in. Be aware that when the sortorder field is set on an item, this overrides all other sorting methods. To use one of the build in sortings, right click on the parent item and choose sorting and subitems sorting.

 

Screenshot of opening the subitems sorting dialog box
 

This opens the following dialog box.

 

Screenshot of sortorder dialog box
 

As you can see, Sitecore has the following six build in sortings.

 

  • Created - Sorts the items by the time they where created with the oldest item first.
  • Default - Sorts the items by their names. This sorting is case insensitive. An example:
    1. Sample Item1
    2. sample Item10
    3. Sample Item2
  • Display Name - Sorts the items by their display names. If an item does not have a display name the item name is used. Contrary to the default sorting this is a logical sorting, where numbers are treated by numerical value instead of ASCII code.  An example:
    1. Sample Item1
    2. sample Item2
    3. Sample Item10
  • Logical - Sorts the item by their name as the default sorting, but treats numbers by their numerical value instead of ASCII codes.
  • Reverse - Sorts the items first by their sortorder but descending and then by their names but reversed. An example:
    1. Sample Item2
    2. sample Item10
    3. Sample Item1
  • Updated - Sorts the items by the time they where last updated. The item that was updated last is sorted first.


As mentioned earlier, if the items has values in the sortorder fields, these values are used to sort the items instead of the method chosen in subitems sorting.


To reset the values of the sortorder fields of all the items, go into the subitems sorting dialog box and click the reset button. This will set the value of all the sortorder fields to 100.

 

Is it possible to change the default sorting?

Yes it is.


To do this you should go to the standard values of the items template.


Here you set the Subitems Sorting field in the Appearance section to the new default sorting.

 

Screenshot of setting sorting on standard values

 

If you cannot see the Appearance section, go to the view tab and check the Standard Fields checkbox.

 

Please rate this article


6 rates / 4,5 avg.

  • Picture of Jimmi Lyhne Andersen

    About the author:

    Jimmi Lyhne Andersen

    Jimmi Lyhne Andersen is the co-founder of LearnSitecore, and is a partner at Inmento Solutions.
    Jimmi has been lead developer and architect on several large public websites with 200+ editors, and is therefore focused on usability and accessibility.
    Jimmi is a certified Sitecore developer and a Microsoft Certified Professional Developer (MCPD).
    He has a bachelors degree in Computer Science and in Mathematics from the University of Copenhagen.

     

4 responses to "Sorting Items"

Thanks for the great article! One useful sorting-related trick I came across a few months ago was the ALT+drag-n-drop method of changing the position of an individual item. For short lists, the up/down/first/last options are handy, but in long lists I find the ALT+drag-n-drop method to be indispensible.
Posted: Thursday, November 05, 2009 2:41 AM
Great that we got this often forgotten feature of Sitecore documented.

I also wrote an article on how to use the same sorting mechanisms on your web site:
http://larsnielsen.blogspirit.com/archive/2009/08/05/sorting-your-items-on-your-website.html
Posted: Thursday, November 05, 2009 7:09 AM
@existdissolve
I didn't know about the ALT+drag-n-drop thing. That is so cool :)

Posted: Thursday, November 05, 2009 2:45 PM
@Jimmi--

To give proper credit, I ran across that nice little nugget here: http://alexeyrusakov.com/sitecoreblog/2008/08/11/Drag+And+Drop+Reordering+In+Sitecore+6.aspx
Posted: Thursday, November 05, 2009 4:02 PM

Leave a reply


Notify me of follow-up comments via email.
 
 
#nbsp;