Golf Score = 487
Uses Kixtart 4.10 + (Requires JOIN)
code:
FUNCTION anagram($J)
DIM $u, $,$a,$b,$c, $I,$O
$u = UBound($J)
$I = S($J) ; Sort the Input array
;
; Create anagram ID's for checking
FOR $ = 0 TO $u
DIM $t[20] ; Len($I[$])
FOR $a = 1 TO Len($I[$])
$t[$a] = Substr($I[$],$a,1)
NEXT
$J[$] = Join(S($t),'')
NEXT
;
; Get anagrams into a new array
;$O = '' $b = ''
FOR EACH $a IN $J ; for each anagram id
DIM $,$d
FOR $c = 0 TO $u
IF $a = $J[$c] AND $a ; If matches anagram id and word not null
$ = $ + ' ' + $I[$c] ; add word to line (already sorted)
$d = 1 + $d ; Increment word count
$J[$c] = 0 ; prevent it being selected again
ENDIF
NEXT
IF $d > 1 ; More than 1 word in anagram line
$O = $O +$b+ Chr($d)+$ ; Add <word count>+<line>
$b = # ; Char to split lines on
ENDIF
NEXT
;
$ = ''
IF $O
$ = S(Split($O,#)) ; Sort by Word count / Alpha
FOR $a = 0 TO Ubound($)
$[$a] = Substr($[$a],3) ; Remove words counter
NEXT
ENDIF
$anagram = $
ENDFUNCTION
;
;
FUNCTION S($) ;Sort routine
DIM $i,$t
FOR EACH $i IN $
FOR $i = 1 TO UBound($)
$t = $[$i-1]
IF $[$i] < $t
$[$i-1] =$[$i] $[$i] =$t
ENDIF
NEXT
NEXT
$S = $
ENDFUNCTION