Hi, this is how I sort a playlist, where I don't want elements to occur more/less often than they do in the original Array. FN NewSortFindHandle& is just NewHandle with a bit of checking. RandomPlayList& is an xref @ array This could probably be faster but it's not in a speed critical area for me. clear local dim Count as unsigned short dim RandomCount as unsigned short local fn RandomisePlayList RandomPlayList& = FN NewSortFindHandle&(RandomPlayList&,SIZEOF(unsigned Short),gNumInPlayList) for Count = 1 to gNumInPlayList RandomPlayList(Count) = 0 next Count = 0 do RandomCount = rnd(gNumInPlayList) long if RandomPlayList(RandomCount) = 0 inc(Count) RandomPlayList(RandomCount) = PlayList(Count) end if until Count = gNumInPlayList for Count = 1 to gNumInPlayList PlayList(Count) = RandomPlayList(Count) next def disposeh (RandomPlayList&) end fn Regards Ian