4

I am writing a script and I get a messege saying my comparisson method violates its general contract.

  array1[i]=array1[i].sort(function (element_a, element_b) {
    if(element_a[typeNum] == element_b[typeNum]){
      return element_b[3+types]-element_a[3+types];
    }
    return element_b[typeNum] - element_a[typeNum];
  });

typeNum and 3+types are both integers. array[i] is a 2D array.

Rubén
  • 34,714
  • 9
  • 70
  • 166
rozi
  • 156
  • 3
  • 1
    possible duplicate : http://stackoverflow.com/questions/8327514/comparison-method-violates-its-general-contract – palanik Mar 22 '14 at 22:07
  • Does this answer your question? ["Comparison method violates its general contract!"](https://stackoverflow.com/questions/8327514/comparison-method-violates-its-general-contract) – tehhowch Jun 27 '20 at 11:33

0 Answers0