Date: Aug 9, 2012 9:53 AM
Subject: Re: Sort vector after relative frequency
"Christian B." wrote in message <email@example.com>...
> Torsten <Torsten.Hennig@umsicht.fraunhofer.de> wrote in message <firstname.lastname@example.org>...
> > Google
> > "sorting an array with minimum number of swaps"
> > Best wishes
> > Torsten.
> Thanks for your answer, but that's not what I'm looking for. The number of swaps does not matter, much more the number of differences between the original and the reordered vector plays a role.
> Maybe sorting is the wrong word, reorder may describe it better. It has nothing to do with ascending or descending, the goal is just to have all numbers of one value contiguously next to each other, while the number of differences between the original and reordered vector should be minimal. Or speaking in matlab code: sum(original==reordered) should be maximized
Why would sort not do this? The intention is for it to sort by value, so wouldn't all the values end up being placed together? This won't minimize the number of changes but you can index where the changes are if you were needing to go back to it?