posted 14 years ago
Obviously that's not your entire code; after all, this method won't compile.
How comparing on multiple fields usually works is as follows:
Note: you can nest the ifs, but that may cause nesting ifs too deeply
In your case, the first comparison is somewhat like this:
You may feel uncomfortable with using nested tertiary operators; you can use simple if statements instead. All that matters is the following matrix:
- blank1 && blank2: both are blank so 0
- blank1 && !blank2: only the first one is blank, so the first one goes before the second one. -1
- !blank1 && blank2: only the second one is blank, so the second one goes before the first one. 1
- !blank1 && !blank2: neither is blank so compare the two