比較しないソートの作成
Posted feedbacks - Smalltalk
Squeak Smalltalk で。
1 2 3 4 5 6 7 8 9 10 11 | | sort |
sort := [:min :max :size :data |
| bag out |
bag := data asBag.
out := OrderedCollection new: size.
min to: max do: [:each |
(bag occurrencesOf: each) timesRepeat: [out add: each]].
out asArray].
sort valueWithArguments: #(-1 10 10 (-1 9 4 8 9 6 3 9 5 2))
"=> #(-1 2 3 4 5 6 8 9 9 9) "
|


sweetie089 #6628() Rating3/3=1.00
[ reply ]