[Squeak] been dazed by SortedCollection

Satoshi NISHIHARA nishis at urban.ne.jp
Sun Aug 30 04:28:27 UTC 1998


Hello Squeakers!

I've been dazed and confused ((C)Led Zeppelin) by SortedCollection.

    | collection |
    collection := SortedCollection new.
    collection sortBlock: [:element1 :element2 | element1 > element2].
    1 to: 10 do: [:i | collection add: i].
    Transcript cr; show: (collection copyFrom: 1 to: 5) printString

Got SortedCollection (6 7 8 9 10 ), although expected SortedCollection
(10 9 8 7 6 ).
I think that SortedCollection (6 7 8 9 10 ) has sortBlock: [:x :y | x <=
y] (default) *not* [:x :y | x > y] (required).  Is it right?


Here is my first aid.

'From Squeak 2.0 of May 22, 1998 on 29 August 1998 at 3:43:36 am'!

!SortedCollection methodsFor: 'copying' stamp: 'nishis 8/29/1998 03:43'!
copyFrom: startIndex to: endIndex 
	"by nishis, 1998/08/29 03:42"

	| targetCollection |
	targetCollection := super copyFrom: startIndex to: endIndex.
	targetCollection sortBlock: sortBlock.
	^targetCollection! !


regards

-- 
--------------------------------------------
$B@>86Ao;N(B (NISHIHARA Satoshi)
e-mail: mailto:nishis at urban.ne.jp
        mailto:tcc00164 at nifty.ne.jp
URL:    http://www.urban.ne.jp/home/nishis/
--------------------------------------------





More information about the Squeak-dev mailing list