I am writing code for Displaying data in ascending order using a TreeMap(). And am in a fix to resolve it. The scenario is

like this i am calling java classes in my application from another application whic is fetching data for me from their

database where i can't intervene. From thisapplication I am calling a class color.java in which objects are defined as

string . And I need to get the data and display the same using my servlet in its ascending order based on its color number.

Like this

ColorNumber Location Qty Price

100 C422 100 20
150 A1100 0575 15
200 D3760 130 500

Also While making call to color.java i get data of following types

colorlocation - Varchar
colornumber - number.
colorqty - number
colorPrice. - number


The piece of java code in my file details.java is like this

Color[] Range= colorenquiry.getColordata();
SortedMap ColorMap = new TreeMap();

for (int i=0; i<Range.length(); i++){

ColorMap.put(Range[i].colornumber, Range[i].colorlocation.toString()+""+

Range[i].colorqty.toString()+""+Range[i].colorprice.toString());

}
System.out.println(ColorMap.keySet());
System.out.println(ColorMap.values());
System.out.println(ColorMap.entrySet());
----------------------------------------------------------

Now the Problem is for few querries iam getting the sorted output as above but for queries where data is like 50- 60 rows am finding sorted data in patches like its 100,150, 200, 300, 500, 350, 600 700 425, 800, 900, 1000, 1100, 1200, 1500,250....
Please advise or have any such working examples where i can refer.

Thanks & Regards,

 

 

 


Reply