compareto

Java's compareTo() function equivalent in Perl?

What's the the Perl function that achieves the same thing as compareTo() in Java? I know about eq and ne but I want to compare to see if one string is greater than another. ...

How to use the Comparable CompareTo on Strings in Java

I can use it to sort by emp id but I'm not sure if it is possible to compare strings. I get an error the operator is undefined for strings. public int compareTo(Emp i) { if (this.getName() == ((Emp ) i).getName()) return 0; else if ((this.getName()) > ((Emp ) i).getName()) return 1...

How do I perform an encoding-independent string-comparison in Java?

I'm having a strange problem comparing strings. I send a string to my server (as bytes using getBytes()) from the client. I've ensured that encoding is the same on the client and server by starting both of them with -Dfile.encoding=UTF-8. I noticed the problem when I was trying to perform a valueOf on the string I receive from the clien...

comparing two TreeNode (or DefaultMutableTreeNode) objects in Java Comparator

Hello everyone! My goal is very simple today, I am trying to work out the proper way to implement compareTo (or the Comparable) interface for my class which extends DefaultMutableTreeNode. The problem is this: Say I have a perfectly good class that represents times. I've already written a perfectly good compareTo method (which works as...

How to compare two datetimes

I wonder how to compare two DateTime objects in .NET using DateTime methods Compare, CompareTo or Equals without comparing ticks. I only need a tolerance level of milliseconds or seconds. How can this be done? ...

How to compare 2 objects of generic type

Is there a way to compare two objects that are generic? I'm supposed to find the largest object in a linked list. My first guess was to use the Object's class compareTo method, but I couldn't get that to work. Thanks ...