Home forums Using CanvasJS Help with Alphabetic sorting?

This topic contains 1 reply, has 2 voices, and was last updated by  Vishwas R 1 month, 3 weeks ago.

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #14114

    Sven0567
    Member

    Hey,

    I’m having a lot of trouble with sorting my labels alphabetically. I’m making a barchart that displays the list of games you own via the Steam API. I’ve managed to sort my data by it’s value, but the alphabetical sorting of the labels looks okay at first glance, but there’s just too many inconsistencies and I don’t this recursion all too well yet.

    This is the code for sorting alphabetically ascending/descending

    function compareDataPointAlphaAscend(dataPoint1, dataPoint2) {
        return dataPoint2.label[0] > dataPoint1.label[0];
    }
    function compareDataPointAlphaDescend(dataPoint1, dataPoint2) {
        return dataPoint1.label[0] > dataPoint2.label[0];
    }

    newData.dataPoints.sort(compareDataPointAlphaAscend);

    But the results are a little inconsistent. There’s always a couple games in there that shouldn’t be.
    i.imgur.com/Nfcd1PL.png
    i.imgur.com/zTYZ083.png

    Thanks

    #14119

    Vishwas R
    Keymaster

    @sven0567,

    Can you kindly create a jsfiddle with the issue, so that we can look into it and help you out?


    Vishwas R

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

You must be logged in to reply to this topic.