Re: Sorting question
Re: Sorting question
- Subject: Re: Sorting question
- From: "Jonathan 'Wolf' Rentzsch" <email@hidden>
- Date: Wed, 22 Sep 2004 12:27:04 -0500
James Cicenia, email@hidden, wrote:
>I thought that EOSortOrderings were just for EOs.
It works fine with anything that supports KVC:
public static void main(String argv[]) {
NSDictionary a = new NSDictionary( "Alice", "name" );
NSDictionary b = new NSDictionary( "Bob", "name" );
NSDictionary c = new NSDictionary( "Carl", "name" );
NSArray unsorted = new NSArray( new Object[]{a,c,b} );
System.out.println( "unsorted: "+unsorted );
EOSortOrdering ascending = EOSortOrdering.sortOrderingWithKey("name",
EOSortOrdering.CompareAscending);
NSArray sortedAscending = EOSortOrdering.sortedArrayUsingKeyOrderArray(
unsorted, new NSArray( ascending ) );
System.out.println( "sortedAscending: "+sortedAscending );
EOSortOrdering descending = EOSortOrdering.sortOrderingWithKey("name",
EOSortOrdering.CompareDescending);
NSArray sortedDescending =
EOSortOrdering.sortedArrayUsingKeyOrderArray( unsorted, new NSArray(
descending ) );
System.out.println( "sortedDescending: "+sortedDescending );
}
output:
unsorted: ({name = "Alice"; }, {name = "Carl"; }, {name = "Bob"; })
sortedAscending: ({name = "Alice"; }, {name = "Bob"; }, {name = "Carl"; })
sortedDescending: ({name = "Carl"; }, {name = "Bob"; }, {name = "Alice";
})
>I just wound up
>creating a simple
>utility class with a compareTo in it. It works.
I'm sure it does. But my way's less code :-)
| Jonathan 'Wolf' Rentzsch http://rentzsch.com
| Red Shed Software http://redshed.net
| "better" necessarily means "different"
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden