Glitch in comparing elements of Integer array in java.

Revision en1, by shubhch32, 2019-03-08 19:46:50

I needed to sort elements for which I used Arrays.sort() function. I read somewhere that it sorts in O(nlogn) time only for arrays containing objects as elements (Integer, Double, etc. but not int, double). But when I was comparing elements in the array after sorting, it showed some weird behaviour. Comparing elements upto 127, it compares correctly but after that it gives wrong results. Any reason as to why?

Here is my code where seq[] is an Integer array (and not int seq[]):

if(seq[i]!=seq[i-1]) map.put(seq[i],count++);

History

 
 
 
 
Revisions
 
 
  Rev. Lang. By When Δ Comment
en1 English shubhch32 2019-03-08 19:46:50 588 Initial revision (published)