Jump to content
xisto Community
Sign in to follow this  
kvarnerexpress

Sortedset/treemap Problem

Recommended Posts

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.colornumber, Range.colorlocation.toString()+""+

 

Range.colorqty.toString()+""+Range.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,

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×
×
  • Create New...

Important Information

Terms of Use | Privacy Policy | Guidelines | We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.