Hi Everyone I have a site where i am trying to sort the entries of a channel by a number. I have two custom fields, one for name and the other for score. The score can be anything from 100 to 0. However, when I order this custom field by the score, it puts everything in order (sort=”desc|asc”) but it places the 100 scores at the bottom.
eg
Name - 99 Name - 90 Name - 74 Name - 100
I assume this is something to do with the fact that EE is sorted based on the first digit, so its thinking its starts with a 1 instead of recognising it by the number of digits, etc.
Does anyone know anyway round this?
Thanks
Steve
This should be possible but you need to make sure the data type (‘Field Content’) is set correctly. Inside the field set up if you select ‘Text Input’ as field type you’ll then have an option at the bottom of the field set up page called ‘Field Content’. Here you have ‘All’, ‘Number’, ‘Integer’ and ‘Decimal’. If you are going to be working with Whole numbers then select ‘Number’.
If your field is set to ‘All’ then it will be treated as alphabetical I.E. 1 comes before (or after, depending on sort order) 9 so you end up with 1,11,100,2,24,9,99 etc, Number should treat them properly as numbers so you’ll have 1,2,9,11,24,99,100.
Hope this helps
Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.