1

I am plotting HighChart Graph .I have data in 2DArray .It contains data as x and y coordinates as

          [0.1.1 , 4.8]
          [0.2.1 ,  5.71]
          [1.1.4 ,  5.79]
          [0.4.3.0 , null]

First column data has to be with 2 decibels ..I cant change 0.1.1 to 0.1

I dont have column Name in Array .I want to sort this array By first Column

I have tried in JSBin

http://jsbin.com/uwIXasa/40/edit

this is not working too I have tried this :

 TestArray.sort(function (a, b) {
            var a1 = a[1], b1 = b[1];
            if (a1 == b1) return 0;
            return a1 > b1 ? 1 : -1;
        });

this is not sorting

I have read similar post ..but many are suggested to solve by column Name

.Please Suggest

user3767164
  • 161
  • 1
  • 7
  • 19
  • sorry sir ..I have Edited the Code – user3767164 Jul 09 '14 at 06:03
  • 3
    Numbers seems to be wrong : 0.1406.0 -> 0.1406 ? – xecgr Jul 09 '14 at 06:03
  • can you write out your variable a little better? what sort of variable is 0.1406.0? is GraphData an array of arrays? why are they all separated like that? – ZekeDroid Jul 09 '14 at 06:04
  • The declaration of `GraphData` would result in a fatal error written like this. – Ja͢ck Jul 09 '14 at 06:05
  • Sir , i Edited my Code ..My Array is not declared right this ..I just took the data at runtime..I was just looking if there is a way to sort data with 2 decibels – user3767164 Jul 09 '14 at 06:08
  • 1
    None of this is valid javascript, numbers can only have one period, you're setting a variable to multiple arrays or something strange etc ? – adeneo Jul 09 '14 at 06:11
  • you can try this: http://stackoverflow.com/questions/18978140/how-to-sort-a-multidimensional-array-in-jquery-by-one-field – Hiren Kagrana Jul 09 '14 at 06:11
  • this is not working sir ..myArray.sort(function(a, b) { return a[1] - b[1]; }); ...not sorting ..I even try My Code in in JSBIn ..this is link http://jsbin.com/uwIXasa/40/edit .. – user3767164 Jul 09 '14 at 06:26
  • 1
    Numbers in Javascript can't be like this, like @adeneo said it's not valid. Why not using Strings and compare them ? (but this still won't work with Highcharts, at least not directly) – Jb Drucker Jul 09 '14 at 08:39
  • Indeed, Highcharts won't display strings as values, however, you can use them as categories. But this: `0.4.3.0` is not proper Javascript number. It will throw an error, so you can't sort that array. – Paweł Fus Jul 09 '14 at 09:06

0 Answers0