%!PS /AddToVector { % val [Vector] AddToVector [NewVector] [ 3 1 roll { 1 index add exch } forall pop ] } bind def /RadixSortCore { % [Vector] max RadixSortCore [NewVector] 5 dict begin /Max exch def /Vect exch def /Radix 1 def { /Vect [ Vect { dup Radix and 0 ne { pop } if } forall Vect { dup Radix and 0 eq { pop } if } forall ] def Radix Max gt { exit } if /Radix Radix dup add def } loop Vect end } bind def /RadixSort { % min max [Vector] RadixSort [NewVector] 2 index neg exch AddToVector exch 2 index sub RadixSortCore AddToVector } bind def % ============ Test Code ============== -1024 2048 [ -510 10 7 12 45 120 -1024 -511 -512 249 1238 1274 ] RadixSort ==