Sort Numbers to the bottom of the list

More
8 years 3 months ago #63461 by rawebcom
I got title list of all the items. It's awesome that there is a function to sort the title according in alphabetical order. But is there any way I could place the title with number at the buttom instead of it displaying it at the top of the list.
This is my list looks like:
1. 911 hotline
2. Aging Department
3. County

Thanks for any help

Please Log in or Create an account to join the conversation.

More
8 years 3 months ago #63479 by rawebcom
Ok. I solved my own problem by using this code in category_items.php
Code:
// Sort in alphabetical and make the numeric title last in order function customSort($a, $b){ if(is_numeric(substr($a->title, 0, 1)) && !is_numeric(substr($b->title, 0, 1))) return 1; else if(!is_numeric(substr($a->title, 0, 1)) && is_numeric(substr($b->title, 0, 1))) return -1; else return ($a->title < $b->title) ? -1 : 1; } usort ( $items , 'customSort' );

Please Log in or Create an account to join the conversation.

Moderators: vistamediajoomlacornerggppdk
Time to create page: 0.367 seconds
Save
Cookies user preferences
We use cookies to ensure you to get the best experience on our website. If you decline the use of cookies, this website may not function as expected.
Accept all
Decline all
Essential
These cookies are needed to make the website work correctly. You can not disable them.
Display
Accept
Analytics
Tools used to analyze the data to measure the effectiveness of a website and to understand how it works.
Google Analytics
Accept
Decline