Home Forums General Issues Number Field – Outputting and Sorting Negative Numbers


Number Field – Outputting and Sorting Negative Numbers

  • As the title suggests, can negative value numbers be correctly output and sorted?

    Looking at the attached, the positive values have output as expected, but the negative values are in reverse order. Any suggestions here?

  • Please provide the code being use to do the sorting.

  • Sorry, it’s list.js –

    I can’t post the entire code here, but the modifier is below and works fine. Like I say, it’s just an issue with negative numbers.

    /* Table Re-Order */
    var options = {
        valueNames: [ 'rank', 'a_level_rank', 'gcse_rank', 'ib_diploma_rank', 'no_of_boarders_rank', 'national_highers_rank', 'advanced_highers_rank', 'maths_rank', 'no_of_maths_candidates_rank', 'sciences_rank', 'no_of_sciences_candidates_rank', 'humanities_rank', 'no_of_humanities_candidates_rank', 'tech_quals_per_student', 'total_tech_exam_entries', 'languages_rank', 'no_of_languages_candidates_rank', 'sports_rank', 'no_of_sports_candidates_rank', 'no_of_oxbridge_applicants_rank', 'no_of_oxbridge_offers_rank', 'oxbridge_rank', 'no_of_russel_group_applicants_rank', 'no_of_russel_group_offers_rank', 'russel_group_rank', 'no_of_med-school_applicants_rank', 'no_of_med_school_offers_rank', 'med_school_rank', 'a-level_value_added_score_rank', 'a-level_retake_grade_increase_rank', 'no_of_ify_students_rank', 'no_of_ify_passes_rank', 'ify_rank', 'academic_value_added_rank' ]
    var userList = new List('league-table', options);
  • That has nothing to do with WP or ACF.

    The values are sorted descending as text strings, not numbers.

    “-” is less than “0” when evaluated as a string, that is why the negatives appear at the end. But “-0.77” is greater than “-0.57” when shorted as a string because “7” (ASCII = 55) > “5” (ASCII = 53). It may not be using ACSII, but 7 is always > 5 when evaluated as a string.

    You should probably ask the developer of list.js

  • Sadly, I thought this may be the case.

    Thanks anyway

Viewing 5 posts - 1 through 5 (of 5 total)

You must be logged in to reply to this topic.