Alternatate methodology using the "Scripting.Dictionary" object. Thought is was fun and it could have competed if M$ did not have such long object and method names.

code:
function CDSorter($T, $m)
; score 240
Dim $b, $c, $
do
$c = split($T,",")
$b = CreateObject("Scripting.Dictionary")
for $=0 to ubound($c)
$b.add($+1, $c[$])
next
do
$b.Remove(RND($))
;remove the '$' above in RND($) to save a stroke,
;but this will dramatically increase runtime.
$=0.0
for each $c in $b.items
$ = $ + $c
next
until $ < $m
until $ > $m-1
$CDSorter=join($b.keys,",")
endfunction

code:
Average CD Length = 44.45
Average Gap = 0.55
Average Gap [%] = 1.23

KiXtart
KiXtart Version = 4.21 Release Candidate 1
KiXGolf Script = kixgolf_cd.kix

Computer
OS = Windows 2000 Professional
CPU = Intel Pentium III
Speed = 848 MHz
Memory = 511 MB

KiXGolf Scoring Engine
Scoring Engine = 3.0.3

KiXtart Golf Score
Tournament = KiXtart Golf: CD Sorter
Processing Start = 2003/03/15 15:06:54.535
Processing End = 2003/03/15 15:07:22.949
Duration = 0000/00/00 00:00:28.413
# Loops = 1
# Processed CDs = 12
# Valid CDs = 12
# Full CDs = 0
KiXGolf Result = Valid CD Filling
KiXGolf Score = 240

_________________________
Home page: http://www.kixhelp.com/hb/