User:Joshbaumgartner/sort by number

Sorting a category by number is done easily by applying a sort key discipline. Category:Items by number is a good example of applying this. Any category that is 'by number' should employ this scheme as it ensures consistent sorting for all numbers up to 99 digits long.

For example, for Category:Items numbered 5000, apply a sort key as shown

[[Category:Items by number| 04 5000]]
  1. After the pipe add a space
  2. Add a two digit number equal to the number of digits in the sorted number (in this case, "5000" has four digits, so "04"). It is important to always include the leading zero for numbers up to 9.
  3. Add another space
  4. Add the sorted number in full with no leading zeros

In this case, in the parent category, it will list all numbers in numerical order, first listing 1-digit numbers (0-9), then 2-digit numbers, and so on.

See Category:Items by number for an example of how to add a TOC that works with these sort keys and allows quick navigation for large categories.

Numbers with decimal positions are easily handled. Simply add another space and add the digits after the decimal place to however many places are needed.