MathGroup Archive 2003

[Date Index] [Thread Index] [Author Index]

Search the Archive

Is Sort stable?


--Short form:
Is the sorting algorithm implemented by Sort[] stable?

--Long form:
I'm doing a thingy where I need to take out subsets of data and look at them
individually. I have a labeled data set, with labels being a vector of 1,2
... denoting class membership, and I've tried to pick out subset using
either e.g.

Extract[data, Position[labels,1]]
=> the data points in "class 1"

or using Sort to sort data according to labels (so I get e.g. {1,1,1,1, ...
2,2,2, ... 3,3,3}, and which is nice for plotting data sets. This work ok,
but it seems like Sort[] is rearranging the data points within classes
different from Extract[]. Does anyone know i Is the Sort[] algorithm stable?
Could there be something else lurking here?


Roland Nilsson
IFM Computational Biology
Linköping University, Sweden
rolle at

  • Prev by Date: RE: Speed Tips
  • Next by Date: RE: thickness of axes
  • Previous by thread: RE: Speed Tips
  • Next by thread: Re: Is Sort stable?