Results 1 to 3 of 3
Thread: sorting problem
- 02-24-2010, 05:37 PM #1
Member
- Join Date
- Jan 2010
- Posts
- 7
- Rep Power
- 0
sorting problem
hi,
Quantity column is of type integer. I need to sort it as integers. I am able to sort the quantity column as strings but not integers. I am giving both the string related and integer related code as follows.
-----------considering quantity as string -----------working-------------
public String sortByQuantity(){
Comparator c = new DbRow(){
public int compare(Object o1, Object o2){
DbRow n1 = (DbRow)o1; DbRow n2 = (DbRow)o2;
return n1.getQuantity().compareTo(n2.getQuantity());
}
};
Arrays.sort(dbrowMain , c);
return null;
}
-------considering quantity as integer type----not working--------
public Integer sortByQuantity(){
Comparator c = new DbRow(){
public int compareTo(Object o1, Object o2){
DbRow n1 = (DbRow)o1; DbRow n2 = (DbRow)o2;
Integer s1= new Integer(n1.getQuantity());
Integer s2 = new Integer(n2.getQuantity());
return s1.compareTo(s2);
}
};
Arrays.sort(dbrowMain , c);
return null;
}
Could you please mention the please give me answer
Thanks in Advance
Vasu
- 02-24-2010, 08:25 PM #2
- Join Date
- Sep 2008
- Location
- Voorschoten, the Netherlands
- Posts
- 11,601
- Blog Entries
- 7
- Rep Power
- 17
- 02-25-2010, 04:55 AM #3
Member
- Join Date
- Feb 2010
- Posts
- 29
- Rep Power
- 0
Similar Threads
-
Problem: Arrays and Sorting
By Rhez in forum New To JavaReplies: 7Last Post: 02-03-2010, 02:18 PM -
Sorting JTable (Vectors) Problem
By ramapple in forum AWT / SwingReplies: 6Last Post: 07-06-2009, 11:15 PM -
sorting problem...
By mark-mlt in forum New To JavaReplies: 4Last Post: 04-17-2008, 02:15 PM -
sorting problem
By mcal in forum New To JavaReplies: 1Last Post: 02-14-2008, 08:13 AM -
Problem with sorting Table
By sireesha264 in forum Advanced JavaReplies: 0Last Post: 02-08-2008, 02:21 PM


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks