Is Sort stable?
- To: mathgroup at smc.vnet.net
- Subject: [mg39725] Is Sort stable?
- From: "Roland Nilsson" <rolle at ifm.liu.se>
- Date: Mon, 3 Mar 2003 23:50:19 -0500 (EST)
- Organization: Island, Linkoping University, Sweden
- Sender: owner-wri-mathgroup at wolfram.com
Hi,
--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?
Regards,
--
---------------------------------------------
Roland Nilsson
IFM Computational Biology
Linköping University, Sweden
rolle at ifm.liu.se