-------------------------------------------------------------------------------
help for sortlistby, sortlistby2
-------------------------------------------------------------------------------

Sort a list at random or by the values of an ancillary number list

sortlistby list , { random | by(numlist) } [ asis noisily ]

sortlistby2 list , { random | by(numlist) } [ asis noisily ]

Description

sortlistby will sort the items in list at random or by the values of an ancillary numlist. sortlistby2 does the same; however, it is a little bit faster if the number of items in list is small (and much slower if the number is large).

Options

asis specifies to take list as is. Default is to treat list as a number list (see numlist).

by(numlist) specifies an ancillary number list (see numlist) according to the values of which list should be sorted.

noisily displays the sorted list.

random specifies to sort list at random.

Examples

. set seed 3273692 . sortlistby 1/1000, random

. sortlistby a b c d e, by(1 5 2 4 3) asis noisily a c e d b

Saved Results

Macros:

r(list) sorted list

Author

Ben Jann, ETH Zurich, jann@soz.gess.ethz.ch

Also see