Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Java Development

Reply
Contributor
Posts: 48
Registered: ‎07-10-2010
My Device: 8300

How to sort Vectors in j2me

Hi,

i have a list field and i want the data in this field to be sorted in alphabetical order.

I think making use of vectors can solve, but please tell me how do we sort a vector in j2me

Developer
Posts: 55
Registered: ‎07-21-2009
My Device: Bold 9700 - 6.0 Bundle 1202 (v6.0.0.344, Platform 6.6.0.50)
My Carrier: Orange UK

Re: How to sort Vectors in j2me

net.rim.device.api.collection.util.SortedReadableList;

 

"It's all about quality (of posts) not quantity"
Contributor
Posts: 48
Registered: ‎07-10-2010
My Device: 8300

Re: How to sort Vectors in j2me

Thanks for the reply,

Please could you provide me with an small piece of code how to start with

Highlighted
Developer
Posts: 203
Registered: ‎07-30-2009
My Device: Bold(9780),Curve(8520)
My Carrier: Vodafone

Re: How to sort Vectors in j2me

Hi

 

try below code to short the vector.

 

 

        Comparator comparator = new Comparator(){
            public int compare(Object o1, Object o2) {
                Integer integer = (Integer)o1;
                Integer integer1 = (Integer)o1;
                if(integer.intValue()>integer.intValue()){
                    return 1;
                }else if(integer.intValue()<integer.intValue()){
                    return 1;
                }
                return 0;
            }
        };


        SimpleSortingVector simpleSortingVector = new SimpleSortingVector();
        simpleSortingVector.setSortComparator(comparator);
        simpleSortingVector.reSort();

 

 

Regards

Tita