Date: Aug 9, 2012 9:53 AM
Author: Kwen
Subject: Re: Sort vector after relative frequency
"Christian B." wrote in message <k00etc$6en$1@newscl01ah.mathworks.com>...
> Torsten <Torsten.Hennig@umsicht.fraunhofer.de> wrote in message <2571f90e-001c-4ec9-8bbc-f2d0e9201722@f2g2000vbm.googlegroups.com>...
> >
> > 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
http://www.mathworks.com/help/techdoc/ref/sortrows.html
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?