Re: Sort Method Conversion



On Wed, 27 Jun 2007 17:07:36 -0700, kaltizer <kevinaltizer@xxxxxxxxx>
wrote, quoted or indirectly quoted someone who said :

I need to modify this method to sort an array of strings rather than
chars:


To write general purpose sorts you need the Comparable or Comparator
interface. You implement the interface to do the compare, and your
sort uses only the methods of those interfaces to do the comparing.

See http://mindprod.com/jgloss/sort.html

http://mindprod.com/jgloss/comparable.html (to define the natural
order)

http://mindprod.com/jgloss/comparator.html(to define alternate orders)
--
Roedy Green Canadian Mind Products
The Java Glossary
http://mindprod.com
.



Relevant Pages

  • Re: Comparator
    ... > public interface myComparator extends Comparator ... This means that everywhere where the compiler ... > - I appreciate very much the ability of Java compiler to recognize ...
    (comp.lang.java.programmer)
  • Re: Comparator
    ... public interface myComparator extends Comparator ... that I don't think sufficiently "Java" yet. ...
    (comp.lang.java.programmer)
  • Re: Newbie question on proper use of Interface
    ... >the reasons a person would use an Interface? ... You might have a peek at some of my sorts that come with source. ... You want to read up on Comparator and ... already have Comparators written to use in Sun sort and Sun ...
    (comp.lang.java.programmer)
  • Re: Sorting based on multiple parameters
    ... Here is what I need to do - I have object MyObj with several fields. ... how do I write comparator for following method? ... List interface contains no sort method. ... Collection interface contains no sort method. ...
    (comp.lang.java.programmer)