Support

Account

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