FSharp, ~207 177
#FSharp, ~207 177
CountCount includes whitespace since its significant for f#
let f w=
let r=System.Random()
let e = Seq.length w
(w|>Seq.mapi(fun i l->if i=0||i=e-1 then i,l else r.Next(1,e-1),l)|>Seq.sortBy fst|>Seq.map snd|>List.ofSeq).ToString()
Run with:
printfn "%s" (f "apples")