Skip to content
Prev 59621 / 398502 Next

sorting without order

"Marc Mamin" <M.Mamin at intershop.de> writes:
Here's one way:

v <- c(10,1,10,100,1,10)
ix <- do.call("c",split(seq(along=v),v))
grouped <- v[ix]

Not sure about the speed though. Should be O(N) if the number of
groups is small, but the multiplier could be large because of various
formalities (such as adding names to ix).