File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

sorting double nodes

 
christopher persinger
Greenhorn
Posts: 20
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Okay I need to create a sort method that will sort double nodes into an ascending list. The elments in the nodes will be Strings so I will need to use a compareTo method in order to tell if it is greater than or less than the String being compared to. Well in our instructions, we are supposed to be using generics. So how can I use a compareTo method if we are using generics? Or is there another way to go about using the insertion sort method of sorting double nodes in a list?? Thanks in advance!
 
Mark Van Tuyl
Ranch Hand
Posts: 60
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
As long as the Objects being compared implement the compareTo() method, there shouldn't be a problem. Your example is using String's, and the String class implements that method.
 
christopher persinger
Greenhorn
Posts: 20
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
But since we are using generics.. how would i create an object to compare?
 
christopher persinger
Greenhorn
Posts: 20
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
basically what im trying to ask is.. how would you use the compareTo method with generics?
 
Layne Lund
Ranch Hand
Posts: 3061
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am not entirely sure what you are asking. Can you post some code for your sort method, and even the class that contains it?

Layne
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic