Re: TMath::Sort

From: Lorenzo Moneta <Lorenzo.Moneta_at_cern.ch>
Date: Tue, 6 Feb 2007 16:16:36 +0100


Hi,

  the algorithm you propose is not very efficient. If you want to preserve the order I would reccomend you to use the algorithms from STL like std::stable_sort.

You can also in STL sorting on the indices by using a functor for the comparison of the values. See in the attached macro for an example

  Cheers

  Lorenzo

On Feb 6, 2007, at 8:13 AM, AJAY KUMAR DASH wrote:

> Hi,
> With this mail I have attached a macro. Which basically does
> sorting of some quantity in a descending
> ( k in my macro) . When I use TMath::Sort, I found, when some
> value of the sorting variable are same
> (10 in my macro) then their index are coming random . Is it
> possible to make the index in a ascending
> order.
>
> With best regards
> AJAY KUMAR DASH
> RESEARCH SCHOLAR
> INSTITUTE OF PHYSICS
> BHUBANESWAR
> ORISSA , INDIA
>
>
>
>
> <Sort1.C>

Received on Tue Feb 06 2007 - 16:17:21 CET

This archive was generated by hypermail 2.2.0 : Tue Feb 06 2007 - 23:50:00 CET