Re: [Mpxj-developers] Sorting by Task.getStart()
Multi platform library to read and write schedule data
Brought to you by:
joniles
|
From: Jon I. <pac...@go...> - 2014-01-14 21:29:48
|
Hi,
here is a code snippet for you showing how to sort a collection using a
Comparator:
public void sortTasks(List<Task> tasks)
{
Collections.sort(tasks, new Comparator<Task>()
{
@Override public int compare(Task o1, Task o2)
{
return DateUtility.compare(o1.getStart(), o2.getStart());
}
});
}
The method performs an "in place" sort of the tasks list, using the compare
method of the Comparator to determine the sort order.
Hope that helps!
Jon
On 31 December 2013 18:46, Blaine <bla...@ya...> wrote:
> Hi, I'm using MPXJ to pull out all the tasks and do some reporting with
> the results. Once I have all my Task objects, I want to present the
> contents sorted by the Start Date. Currently I have a List containing all
> my Task objects, but I'd like to display them sorted based on the result
> of Task.getStart().
>
> I'm writing this in Groovy/Java. I haven't been able to figure out how to
> do the sort. From what I read, I think there's something close to possible
> since it implements Comparable, but I can't figure out how.
>
> Any code examples of how to do this?
>
> Thanks in advance,
> Blaine
>
>
>
>
> ------------------------------------------------------------------------------
> Rapidly troubleshoot problems before they affect your business. Most IT
> organizations don't have a clear picture of how application performance
> affects their revenue. With AppDynamics, you get 100% visibility into your
> Java,.NET, & PHP application. Start your 15-day FREE TRIAL of AppDynamics
> Pro!
> http://pubads.g.doubleclick.net/gampad/clk?id=84349831&iu=/4140/ostg.clktrk
> _______________________________________________
> Mpxj-developers mailing list
> Mpx...@li...
> https://lists.sourceforge.net/lists/listinfo/mpxj-developers
>
>
|