Home › Forums › Front-end Issues › Strange results when using orderby a number field › Reply To: Strange results when using orderby a number field
The loop is fine.
The problem is that the jQuery table I’m using (was using, Im trying a different script now) to SORT the data is confusing the parsed numbers with commas as regular strings, not as numbers/values so it orders as 1,100, 1000,2, 20, 2222, 6 instead of 1,2,6,20,100,1000,2222
The problem seems to be that converting the string with <?php echo number_format( floatval( get_field(‘revenue_number’) ), 0, ‘.’, ‘,’ ); ?> confuses the sorter.
If I don’t convert it and just use the regular the_field call, it sorts properly.
I don’t know if there’s a way to call the conversion in the loop prior to the while/loop or if there’s a different way to convert the output
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Privacy Policy. If you continue to use this site, you consent to our use of cookies.