Gossamer Forum
Home : Products : Gossamer Links : Discussions :

How do I sort number by its values?

Quote Reply
How do I sort number by its values?
Hi, I succeeded in sorting by title. Some of my titles invovle numbers such as 1, 2, 5, 6, 7. Now they are sorted by 1, 11, 12, 2, 3, 33, 4, which is not what I want. I need sort links by title and if there are numbers in titles, they need to compare the real values of titles. What should I enter in Admin-setup-build options in addition to "Title ASC{"?
Quote Reply
Re: [banana] How do I sort number by its values? In reply to
Zero-padding the numbers will give the correct results in the sort, e.g.;

0001, 0002, 0003, 0010, 0011, 0015, 0023, etc.

... but you'd want to remove the leading zero's at print / build time.

You probably want to look at Build.pm in the build_title_* subs - someone else will have to give you the perl for removing the zero's as I don't know what it should be - sorry.

All the best
Shaun