SequenceableCollectionSorter.st
author Claus Gittinger <cg@exept.de>
Tue, 25 Jun 2019 14:28:51 +0200
changeset 5050 44fa8672d102
parent 4281 c0457c1b6e53
child 5209 6ea076e6515d
permissions -rw-r--r--
#DOCUMENTATION by cg class: SharedQueue comment/format in: #next #nextWithTimeout:
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
4281
c0457c1b6e53 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
     1
"
c0457c1b6e53 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
     2
 COPYRIGHT (c) 1996 by Claus Gittinger
c0457c1b6e53 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
     3
              All Rights Reserved
c0457c1b6e53 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
     4
c0457c1b6e53 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
     5
 This software is furnished under a license and may be used
c0457c1b6e53 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
     6
 only in accordance with the terms of that license and with the
c0457c1b6e53 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
     7
 inclusion of the above copyright notice.   This software may not
c0457c1b6e53 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
     8
 be provided or otherwise made available to, or used by, any
c0457c1b6e53 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
     9
 other person.  No title to or ownership of the software is
c0457c1b6e53 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
    10
 hereby transferred.
c0457c1b6e53 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
    11
"
c0457c1b6e53 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
    12
"{ Package: 'stx:libbasic2' }"
c0457c1b6e53 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
    13
c0457c1b6e53 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
    14
"{ NameSpace: Smalltalk }"
c0457c1b6e53 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
    15
182
2ba5785a441e intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    16
Object subclass:#SequenceableCollectionSorter
2ba5785a441e intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    17
	instanceVariableNames:'collection atSelector putSelector sizeSelector sortBlock'
2ba5785a441e intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    18
	classVariableNames:'DefaultSortBlock'
2ba5785a441e intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    19
	poolDictionaries:''
2ba5785a441e intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    20
	category:'Collections-Support'
2ba5785a441e intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    21
!
2ba5785a441e intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    22
2ba5785a441e intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    23
!SequenceableCollectionSorter class methodsFor:'documentation'!
2ba5785a441e intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    24
4281
c0457c1b6e53 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
    25
copyright
c0457c1b6e53 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
    26
"
c0457c1b6e53 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
    27
 COPYRIGHT (c) 1996 by Claus Gittinger
c0457c1b6e53 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
    28
              All Rights Reserved
c0457c1b6e53 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
    29
c0457c1b6e53 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
    30
 This software is furnished under a license and may be used
c0457c1b6e53 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
    31
 only in accordance with the terms of that license and with the
c0457c1b6e53 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
    32
 inclusion of the above copyright notice.   This software may not
c0457c1b6e53 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
    33
 be provided or otherwise made available to, or used by, any
c0457c1b6e53 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
    34
 other person.  No title to or ownership of the software is
c0457c1b6e53 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
    35
 hereby transferred.
c0457c1b6e53 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
    36
"
c0457c1b6e53 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
    37
!
c0457c1b6e53 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
    38
182
2ba5785a441e intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    39
documentation
2ba5785a441e intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    40
"
2ba5785a441e intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    41
    a SequenceableCollectionSorter allows for anything which responds to
2ba5785a441e intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    42
    keyed at/atPut messages to be sorted just like a SequenceableCollection.
183
01781ca31dad really use #<= for comparing (used #<)
Claus Gittinger <cg@exept.de>
parents: 182
diff changeset
    43
    Since the access messages can be customized, even non collections
01781ca31dad really use #<= for comparing (used #<)
Claus Gittinger <cg@exept.de>
parents: 182
diff changeset
    44
    (or collection simulators, models etc.) can be sorted with these sorters.
182
2ba5785a441e intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    45
    (use #atSelector: / #putSelector: and #sizeSelector: for customization).
2ba5785a441e intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    46
2ba5785a441e intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    47
    As with collection sorting, the sortBlock can be specified and defaults to
2ba5785a441e intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    48
    a block which compares using #< messages.
2ba5785a441e intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    49
"
2ba5785a441e intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    50
!
2ba5785a441e intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    51
2ba5785a441e intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    52
examples
2ba5785a441e intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    53
"
2ba5785a441e intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    54
    |a sorter|
2ba5785a441e intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    55
2ba5785a441e intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    56
    a := #(10 5 2 17 5 99 -5).
2ba5785a441e intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    57
    sorter := SequenceableCollectionSorter on:a.
2ba5785a441e intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    58
    sorter sort.
350
93d5932c76e6 showCr: -> showCR:
Claus Gittinger <cg@exept.de>
parents: 184
diff changeset
    59
    Transcript showCR:a printString
182
2ba5785a441e intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    60
"
2ba5785a441e intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    61
! !
2ba5785a441e intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    62
2ba5785a441e intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    63
!SequenceableCollectionSorter class methodsFor:'initialization'!
2ba5785a441e intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    64
2ba5785a441e intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    65
initialize
2ba5785a441e intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    66
    DefaultSortBlock := [:a :b | a <= b]
2ba5785a441e intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    67
2ba5785a441e intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    68
    "
2ba5785a441e intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    69
     SequenceableCollectionSorter initialize
2ba5785a441e intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    70
    "
2ba5785a441e intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    71
2ba5785a441e intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    72
    "Modified: 6.2.1996 / 15:47:48 / cg"
2ba5785a441e intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    73
! !
2ba5785a441e intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    74
2ba5785a441e intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    75
!SequenceableCollectionSorter class methodsFor:'instance creation'!
2ba5785a441e intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    76
2ba5785a441e intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    77
on:aCollection
2ba5785a441e intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    78
    ^ self new collection:aCollection; sortBlock:DefaultSortBlock
2ba5785a441e intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    79
2ba5785a441e intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    80
    "Created: 6.2.1996 / 15:39:09 / cg"
2ba5785a441e intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    81
    "Modified: 6.2.1996 / 16:07:36 / cg"
2ba5785a441e intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    82
!
2ba5785a441e intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    83
2ba5785a441e intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    84
on:aCollection using:aTwoArgBlock
2ba5785a441e intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    85
    ^ self new collection:aCollection; sortBlock:aTwoArgBlock
2ba5785a441e intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    86
2ba5785a441e intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    87
    "Created: 6.2.1996 / 15:39:32 / cg"
2ba5785a441e intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    88
!
2ba5785a441e intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    89
2ba5785a441e intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    90
sort:aCollection
2ba5785a441e intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    91
    (self new collection:aCollection; sortBlock:DefaultSortBlock) sort
2ba5785a441e intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    92
2ba5785a441e intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    93
    "Created: 6.2.1996 / 15:40:04 / cg"
2ba5785a441e intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    94
    "Modified: 6.2.1996 / 16:07:42 / cg"
2ba5785a441e intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    95
!
2ba5785a441e intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    96
2ba5785a441e intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    97
sort:aCollection using:aTwoArgBlock
2ba5785a441e intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    98
    (self new collection:aCollection; sortBlock:aTwoArgBlock) sort
2ba5785a441e intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    99
2ba5785a441e intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   100
    "Created: 6.2.1996 / 15:39:58 / cg"
2ba5785a441e intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   101
! !
2ba5785a441e intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   102
2ba5785a441e intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   103
!SequenceableCollectionSorter methodsFor:'accessing'!
2ba5785a441e intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   104
2ba5785a441e intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   105
atSelector:aSymbol
2ba5785a441e intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   106
    "set the selector to access elements.
2ba5785a441e intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   107
     If nil (the default), elements are accessed via #at:"
2ba5785a441e intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   108
2ba5785a441e intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   109
    atSelector := aSymbol
2ba5785a441e intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   110
2ba5785a441e intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   111
    "Created: 6.2.1996 / 15:35:49 / cg"
2ba5785a441e intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   112
!
2ba5785a441e intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   113
2ba5785a441e intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   114
collection
2ba5785a441e intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   115
    "return the collections being sorted."
2ba5785a441e intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   116
2ba5785a441e intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   117
    ^ collection
2ba5785a441e intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   118
2ba5785a441e intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   119
    "Created: 6.2.1996 / 15:37:02 / cg"
2ba5785a441e intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   120
!
2ba5785a441e intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   121
2ba5785a441e intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   122
collection:aCollection
2ba5785a441e intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   123
    "set the collections being sorted."
2ba5785a441e intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   124
2ba5785a441e intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   125
    collection := aCollection
2ba5785a441e intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   126
2ba5785a441e intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   127
    "Created: 6.2.1996 / 15:37:20 / cg"
2ba5785a441e intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   128
!
2ba5785a441e intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   129
2ba5785a441e intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   130
putSelector:aSymbol
2ba5785a441e intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   131
    "set the selector to access elements.
2ba5785a441e intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   132
     If nil (the default), elements are accessed via #at:put:"
2ba5785a441e intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   133
2ba5785a441e intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   134
    putSelector := aSymbol
2ba5785a441e intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   135
2ba5785a441e intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   136
    "Created: 6.2.1996 / 15:36:14 / cg"
2ba5785a441e intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   137
!
2ba5785a441e intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   138
2ba5785a441e intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   139
sizeSelector:aSymbol
2ba5785a441e intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   140
    "set the selector to get the collections size.
2ba5785a441e intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   141
     If nil (the default), elements are accessed via #size"
2ba5785a441e intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   142
2ba5785a441e intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   143
    sizeSelector := aSymbol
2ba5785a441e intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   144
2ba5785a441e intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   145
    "Created: 6.2.1996 / 15:36:33 / cg"
2ba5785a441e intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   146
!
2ba5785a441e intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   147
2ba5785a441e intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   148
sortBlock
2ba5785a441e intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   149
    "return the sortBlock which is used to compare two elements.
2ba5785a441e intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   150
     The default sortBlock compares elements by sending the #< message."
2ba5785a441e intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   151
2ba5785a441e intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   152
    ^ sortBlock
2ba5785a441e intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   153
2ba5785a441e intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   154
    "Created: 6.2.1996 / 15:38:32 / cg"
2ba5785a441e intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   155
!
2ba5785a441e intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   156
2ba5785a441e intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   157
sortBlock:aTwoArgBlock 
2ba5785a441e intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   158
    "set the sortBlock which is used to compare two elements.
2ba5785a441e intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   159
     The default sortBlock compares elements by sending the #< message."
2ba5785a441e intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   160
2ba5785a441e intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   161
    sortBlock := aTwoArgBlock
2ba5785a441e intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   162
2ba5785a441e intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   163
    "Created: 6.2.1996 / 15:38:20 / cg"
2ba5785a441e intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   164
! !
2ba5785a441e intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   165
2ba5785a441e intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   166
!SequenceableCollectionSorter methodsFor:'sorting'!
2ba5785a441e intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   167
2ba5785a441e intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   168
defaultSort:inBegin to:inEnd
2ba5785a441e intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   169
    "actual sort worker for sorting when the sortBlock is nil (or the default)
184
9200f060f2dc commentary
Claus Gittinger <cg@exept.de>
parents: 183
diff changeset
   170
     and default atSelector/putSelectors are to be used.
9200f060f2dc commentary
Claus Gittinger <cg@exept.de>
parents: 183
diff changeset
   171
     This will execute slightly faster, since no #perform-indirection is needed."
182
2ba5785a441e intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   172
2ba5785a441e intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   173
    |begin   "{ Class: SmallInteger }"
2ba5785a441e intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   174
     end     "{ Class: SmallInteger }"
2ba5785a441e intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   175
     b       "{ Class: SmallInteger }"
2ba5785a441e intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   176
     e       "{ Class: SmallInteger }"
2ba5785a441e intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   177
     middleElement temp1 temp2 |
2ba5785a441e intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   178
2ba5785a441e intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   179
    begin := inBegin.   "/ this also does a type-check
2ba5785a441e intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   180
    end := inEnd.
2ba5785a441e intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   181
2ba5785a441e intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   182
    b := begin.
2ba5785a441e intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   183
    e := end.
2ba5785a441e intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   184
    middleElement := collection at:((b + e) // 2).
2ba5785a441e intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   185
2ba5785a441e intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   186
    [b < e] whileTrue:[
183
01781ca31dad really use #<= for comparing (used #<)
Claus Gittinger <cg@exept.de>
parents: 182
diff changeset
   187
        [b < end and:[(collection at:b) <= middleElement]] whileTrue:[b := b + 1].
01781ca31dad really use #<= for comparing (used #<)
Claus Gittinger <cg@exept.de>
parents: 182
diff changeset
   188
        [e > begin and:[middleElement <= (collection at:e)]] whileTrue:[e := e - 1].
182
2ba5785a441e intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   189
2ba5785a441e intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   190
        (b <= e) ifTrue:[
2ba5785a441e intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   191
            (b == e) ifFalse:[
2ba5785a441e intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   192
                temp1 := collection at:b. temp2 := collection at:e. 
2ba5785a441e intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   193
                collection at:b put:temp2. collection at:e put:temp1
2ba5785a441e intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   194
            ].
2ba5785a441e intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   195
            b := b + 1.
2ba5785a441e intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   196
            e := e - 1
2ba5785a441e intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   197
        ]
2ba5785a441e intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   198
    ].
2ba5785a441e intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   199
    (begin < e) ifTrue:[self defaultSort:begin to:e].
2ba5785a441e intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   200
    (b < end) ifTrue:[self defaultSort:b to:end]
2ba5785a441e intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   201
2ba5785a441e intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   202
    "Created: 6.2.1996 / 15:44:37 / cg"
184
9200f060f2dc commentary
Claus Gittinger <cg@exept.de>
parents: 183
diff changeset
   203
    "Modified: 6.2.1996 / 18:06:23 / cg"
182
2ba5785a441e intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   204
!
2ba5785a441e intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   205
585
ab03e26e2df1 support 3-arg sorting using a collationPolicy
Claus Gittinger <cg@exept.de>
parents: 350
diff changeset
   206
nonDefaultSort3:inBegin to:inEnd with:p
ab03e26e2df1 support 3-arg sorting using a collationPolicy
Claus Gittinger <cg@exept.de>
parents: 350
diff changeset
   207
    "actual sort worker for sorting when a non default sortBlock
ab03e26e2df1 support 3-arg sorting using a collationPolicy
Claus Gittinger <cg@exept.de>
parents: 350
diff changeset
   208
     with 3 args (stringSort) is used."
ab03e26e2df1 support 3-arg sorting using a collationPolicy
Claus Gittinger <cg@exept.de>
parents: 350
diff changeset
   209
ab03e26e2df1 support 3-arg sorting using a collationPolicy
Claus Gittinger <cg@exept.de>
parents: 350
diff changeset
   210
    |begin   "{ Class: SmallInteger }"
ab03e26e2df1 support 3-arg sorting using a collationPolicy
Claus Gittinger <cg@exept.de>
parents: 350
diff changeset
   211
     end     "{ Class: SmallInteger }"
ab03e26e2df1 support 3-arg sorting using a collationPolicy
Claus Gittinger <cg@exept.de>
parents: 350
diff changeset
   212
     b       "{ Class: SmallInteger }"
ab03e26e2df1 support 3-arg sorting using a collationPolicy
Claus Gittinger <cg@exept.de>
parents: 350
diff changeset
   213
     e       "{ Class: SmallInteger }"
ab03e26e2df1 support 3-arg sorting using a collationPolicy
Claus Gittinger <cg@exept.de>
parents: 350
diff changeset
   214
     middleElement temp1 temp2 
ab03e26e2df1 support 3-arg sorting using a collationPolicy
Claus Gittinger <cg@exept.de>
parents: 350
diff changeset
   215
     atSel putSel|
ab03e26e2df1 support 3-arg sorting using a collationPolicy
Claus Gittinger <cg@exept.de>
parents: 350
diff changeset
   216
ab03e26e2df1 support 3-arg sorting using a collationPolicy
Claus Gittinger <cg@exept.de>
parents: 350
diff changeset
   217
    atSel := atSelector ? #at:.
ab03e26e2df1 support 3-arg sorting using a collationPolicy
Claus Gittinger <cg@exept.de>
parents: 350
diff changeset
   218
    putSel := putSelector ? #at:put:.
ab03e26e2df1 support 3-arg sorting using a collationPolicy
Claus Gittinger <cg@exept.de>
parents: 350
diff changeset
   219
ab03e26e2df1 support 3-arg sorting using a collationPolicy
Claus Gittinger <cg@exept.de>
parents: 350
diff changeset
   220
    begin := inBegin.   "/ this also does a type-check
ab03e26e2df1 support 3-arg sorting using a collationPolicy
Claus Gittinger <cg@exept.de>
parents: 350
diff changeset
   221
    end := inEnd.
ab03e26e2df1 support 3-arg sorting using a collationPolicy
Claus Gittinger <cg@exept.de>
parents: 350
diff changeset
   222
ab03e26e2df1 support 3-arg sorting using a collationPolicy
Claus Gittinger <cg@exept.de>
parents: 350
diff changeset
   223
    b := begin.
ab03e26e2df1 support 3-arg sorting using a collationPolicy
Claus Gittinger <cg@exept.de>
parents: 350
diff changeset
   224
    e := end.
ab03e26e2df1 support 3-arg sorting using a collationPolicy
Claus Gittinger <cg@exept.de>
parents: 350
diff changeset
   225
    middleElement := collection perform:atSel with:((b + e) // 2).
ab03e26e2df1 support 3-arg sorting using a collationPolicy
Claus Gittinger <cg@exept.de>
parents: 350
diff changeset
   226
ab03e26e2df1 support 3-arg sorting using a collationPolicy
Claus Gittinger <cg@exept.de>
parents: 350
diff changeset
   227
    [b < e] whileTrue:[
ab03e26e2df1 support 3-arg sorting using a collationPolicy
Claus Gittinger <cg@exept.de>
parents: 350
diff changeset
   228
        [b < end 
ab03e26e2df1 support 3-arg sorting using a collationPolicy
Claus Gittinger <cg@exept.de>
parents: 350
diff changeset
   229
        and:[sortBlock 
ab03e26e2df1 support 3-arg sorting using a collationPolicy
Claus Gittinger <cg@exept.de>
parents: 350
diff changeset
   230
                value:p
ab03e26e2df1 support 3-arg sorting using a collationPolicy
Claus Gittinger <cg@exept.de>
parents: 350
diff changeset
   231
                value:(collection perform:atSel with:b)
ab03e26e2df1 support 3-arg sorting using a collationPolicy
Claus Gittinger <cg@exept.de>
parents: 350
diff changeset
   232
                value:middleElement]] 
ab03e26e2df1 support 3-arg sorting using a collationPolicy
Claus Gittinger <cg@exept.de>
parents: 350
diff changeset
   233
        whileTrue:[b := b + 1].
ab03e26e2df1 support 3-arg sorting using a collationPolicy
Claus Gittinger <cg@exept.de>
parents: 350
diff changeset
   234
        [e > begin 
ab03e26e2df1 support 3-arg sorting using a collationPolicy
Claus Gittinger <cg@exept.de>
parents: 350
diff changeset
   235
        and:[sortBlock
ab03e26e2df1 support 3-arg sorting using a collationPolicy
Claus Gittinger <cg@exept.de>
parents: 350
diff changeset
   236
                value:p
ab03e26e2df1 support 3-arg sorting using a collationPolicy
Claus Gittinger <cg@exept.de>
parents: 350
diff changeset
   237
                value:middleElement
ab03e26e2df1 support 3-arg sorting using a collationPolicy
Claus Gittinger <cg@exept.de>
parents: 350
diff changeset
   238
                value:(collection perform:atSel with:e)]] 
ab03e26e2df1 support 3-arg sorting using a collationPolicy
Claus Gittinger <cg@exept.de>
parents: 350
diff changeset
   239
        whileTrue:[e := e - 1].
ab03e26e2df1 support 3-arg sorting using a collationPolicy
Claus Gittinger <cg@exept.de>
parents: 350
diff changeset
   240
ab03e26e2df1 support 3-arg sorting using a collationPolicy
Claus Gittinger <cg@exept.de>
parents: 350
diff changeset
   241
        (b <= e) ifTrue:[
ab03e26e2df1 support 3-arg sorting using a collationPolicy
Claus Gittinger <cg@exept.de>
parents: 350
diff changeset
   242
            (b == e) ifFalse:[
ab03e26e2df1 support 3-arg sorting using a collationPolicy
Claus Gittinger <cg@exept.de>
parents: 350
diff changeset
   243
                temp1 := (collection perform:atSel with:b). 
ab03e26e2df1 support 3-arg sorting using a collationPolicy
Claus Gittinger <cg@exept.de>
parents: 350
diff changeset
   244
                temp2 := (collection perform:atSel with:e). 
ab03e26e2df1 support 3-arg sorting using a collationPolicy
Claus Gittinger <cg@exept.de>
parents: 350
diff changeset
   245
                collection perform:putSel with:b with:temp2. 
ab03e26e2df1 support 3-arg sorting using a collationPolicy
Claus Gittinger <cg@exept.de>
parents: 350
diff changeset
   246
                collection perform:putSel with:e with:temp1.
ab03e26e2df1 support 3-arg sorting using a collationPolicy
Claus Gittinger <cg@exept.de>
parents: 350
diff changeset
   247
            ].
ab03e26e2df1 support 3-arg sorting using a collationPolicy
Claus Gittinger <cg@exept.de>
parents: 350
diff changeset
   248
            b := b + 1.
ab03e26e2df1 support 3-arg sorting using a collationPolicy
Claus Gittinger <cg@exept.de>
parents: 350
diff changeset
   249
            e := e - 1
ab03e26e2df1 support 3-arg sorting using a collationPolicy
Claus Gittinger <cg@exept.de>
parents: 350
diff changeset
   250
        ]
ab03e26e2df1 support 3-arg sorting using a collationPolicy
Claus Gittinger <cg@exept.de>
parents: 350
diff changeset
   251
    ].
ab03e26e2df1 support 3-arg sorting using a collationPolicy
Claus Gittinger <cg@exept.de>
parents: 350
diff changeset
   252
    (begin < e) ifTrue:[self nonDefaultSort3:begin to:e with:p].
ab03e26e2df1 support 3-arg sorting using a collationPolicy
Claus Gittinger <cg@exept.de>
parents: 350
diff changeset
   253
    (b < end) ifTrue:[self nonDefaultSort3:b to:end with:p]
ab03e26e2df1 support 3-arg sorting using a collationPolicy
Claus Gittinger <cg@exept.de>
parents: 350
diff changeset
   254
ab03e26e2df1 support 3-arg sorting using a collationPolicy
Claus Gittinger <cg@exept.de>
parents: 350
diff changeset
   255
    "Modified: / 27.10.1997 / 04:52:41 / cg"
ab03e26e2df1 support 3-arg sorting using a collationPolicy
Claus Gittinger <cg@exept.de>
parents: 350
diff changeset
   256
    "Created: / 27.10.1997 / 18:54:54 / cg"
ab03e26e2df1 support 3-arg sorting using a collationPolicy
Claus Gittinger <cg@exept.de>
parents: 350
diff changeset
   257
!
ab03e26e2df1 support 3-arg sorting using a collationPolicy
Claus Gittinger <cg@exept.de>
parents: 350
diff changeset
   258
182
2ba5785a441e intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   259
nonDefaultSort:inBegin to:inEnd
2ba5785a441e intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   260
    "actual sort worker for sorting when a non default sortBlock
184
9200f060f2dc commentary
Claus Gittinger <cg@exept.de>
parents: 183
diff changeset
   261
     or nonNil access selectors are used."
182
2ba5785a441e intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   262
2ba5785a441e intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   263
    |begin   "{ Class: SmallInteger }"
2ba5785a441e intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   264
     end     "{ Class: SmallInteger }"
2ba5785a441e intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   265
     b       "{ Class: SmallInteger }"
2ba5785a441e intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   266
     e       "{ Class: SmallInteger }"
585
ab03e26e2df1 support 3-arg sorting using a collationPolicy
Claus Gittinger <cg@exept.de>
parents: 350
diff changeset
   267
     middleElement temp1 temp2 
ab03e26e2df1 support 3-arg sorting using a collationPolicy
Claus Gittinger <cg@exept.de>
parents: 350
diff changeset
   268
     atSel putSel|
ab03e26e2df1 support 3-arg sorting using a collationPolicy
Claus Gittinger <cg@exept.de>
parents: 350
diff changeset
   269
ab03e26e2df1 support 3-arg sorting using a collationPolicy
Claus Gittinger <cg@exept.de>
parents: 350
diff changeset
   270
    atSel := atSelector ? #at:.
ab03e26e2df1 support 3-arg sorting using a collationPolicy
Claus Gittinger <cg@exept.de>
parents: 350
diff changeset
   271
    putSel := putSelector ? #at:put:.
182
2ba5785a441e intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   272
2ba5785a441e intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   273
    begin := inBegin.   "/ this also does a type-check
2ba5785a441e intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   274
    end := inEnd.
2ba5785a441e intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   275
2ba5785a441e intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   276
    b := begin.
2ba5785a441e intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   277
    e := end.
585
ab03e26e2df1 support 3-arg sorting using a collationPolicy
Claus Gittinger <cg@exept.de>
parents: 350
diff changeset
   278
    middleElement := collection perform:atSel with:((b + e) // 2).
182
2ba5785a441e intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   279
2ba5785a441e intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   280
    [b < e] whileTrue:[
2ba5785a441e intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   281
        [b < end 
2ba5785a441e intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   282
        and:[sortBlock 
585
ab03e26e2df1 support 3-arg sorting using a collationPolicy
Claus Gittinger <cg@exept.de>
parents: 350
diff changeset
   283
                value:(collection perform:atSel with:b)
182
2ba5785a441e intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   284
                value:middleElement]] 
2ba5785a441e intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   285
        whileTrue:[b := b + 1].
2ba5785a441e intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   286
        [e > begin 
2ba5785a441e intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   287
        and:[sortBlock
2ba5785a441e intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   288
                value:middleElement
585
ab03e26e2df1 support 3-arg sorting using a collationPolicy
Claus Gittinger <cg@exept.de>
parents: 350
diff changeset
   289
                value:(collection perform:atSel with:e)]] 
182
2ba5785a441e intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   290
        whileTrue:[e := e - 1].
2ba5785a441e intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   291
2ba5785a441e intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   292
        (b <= e) ifTrue:[
2ba5785a441e intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   293
            (b == e) ifFalse:[
585
ab03e26e2df1 support 3-arg sorting using a collationPolicy
Claus Gittinger <cg@exept.de>
parents: 350
diff changeset
   294
                temp1 := (collection perform:atSel with:b). 
ab03e26e2df1 support 3-arg sorting using a collationPolicy
Claus Gittinger <cg@exept.de>
parents: 350
diff changeset
   295
                temp2 := (collection perform:atSel with:e). 
ab03e26e2df1 support 3-arg sorting using a collationPolicy
Claus Gittinger <cg@exept.de>
parents: 350
diff changeset
   296
                collection perform:putSel with:b with:temp2. 
ab03e26e2df1 support 3-arg sorting using a collationPolicy
Claus Gittinger <cg@exept.de>
parents: 350
diff changeset
   297
                collection perform:putSel with:e with:temp1.
182
2ba5785a441e intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   298
            ].
2ba5785a441e intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   299
            b := b + 1.
2ba5785a441e intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   300
            e := e - 1
2ba5785a441e intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   301
        ]
2ba5785a441e intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   302
    ].
2ba5785a441e intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   303
    (begin < e) ifTrue:[self nonDefaultSort:begin to:e].
2ba5785a441e intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   304
    (b < end) ifTrue:[self nonDefaultSort:b to:end]
2ba5785a441e intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   305
585
ab03e26e2df1 support 3-arg sorting using a collationPolicy
Claus Gittinger <cg@exept.de>
parents: 350
diff changeset
   306
    "Created: / 6.2.1996 / 16:06:46 / cg"
ab03e26e2df1 support 3-arg sorting using a collationPolicy
Claus Gittinger <cg@exept.de>
parents: 350
diff changeset
   307
    "Modified: / 27.10.1997 / 04:52:41 / cg"
182
2ba5785a441e intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   308
!
2ba5785a441e intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   309
2ba5785a441e intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   310
sort
2ba5785a441e intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   311
    |sz|
2ba5785a441e intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   312
2ba5785a441e intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   313
    sizeSelector isNil ifTrue:[
2ba5785a441e intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   314
        sz := collection size
2ba5785a441e intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   315
    ] ifFalse:[
2ba5785a441e intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   316
        sz := collection perform:sizeSelector
2ba5785a441e intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   317
    ].
2ba5785a441e intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   318
    self sort:1 to:sz
2ba5785a441e intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   319
2ba5785a441e intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   320
    "Created: 6.2.1996 / 15:41:21 / cg"
2ba5785a441e intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   321
!
2ba5785a441e intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   322
2ba5785a441e intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   323
sort:from to:to 
2ba5785a441e intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   324
    "actual sort worker for sort-messages"
2ba5785a441e intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   325
2ba5785a441e intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   326
    (atSelector isNil
2ba5785a441e intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   327
    and:[putSelector isNil
2ba5785a441e intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   328
    and:[sortBlock isNil or:[sortBlock == DefaultSortBlock]]]) ifTrue:[
2ba5785a441e intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   329
        self defaultSort:from to:to 
2ba5785a441e intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   330
    ] ifFalse:[
585
ab03e26e2df1 support 3-arg sorting using a collationPolicy
Claus Gittinger <cg@exept.de>
parents: 350
diff changeset
   331
        sortBlock numArgs == 3 ifTrue:[
ab03e26e2df1 support 3-arg sorting using a collationPolicy
Claus Gittinger <cg@exept.de>
parents: 350
diff changeset
   332
            self nonDefaultSort3:from to:to with:nil "p"
ab03e26e2df1 support 3-arg sorting using a collationPolicy
Claus Gittinger <cg@exept.de>
parents: 350
diff changeset
   333
        ] ifFalse:[
ab03e26e2df1 support 3-arg sorting using a collationPolicy
Claus Gittinger <cg@exept.de>
parents: 350
diff changeset
   334
            self nonDefaultSort:from to:to
ab03e26e2df1 support 3-arg sorting using a collationPolicy
Claus Gittinger <cg@exept.de>
parents: 350
diff changeset
   335
        ]
182
2ba5785a441e intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   336
    ].
2ba5785a441e intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   337
585
ab03e26e2df1 support 3-arg sorting using a collationPolicy
Claus Gittinger <cg@exept.de>
parents: 350
diff changeset
   338
    "Modified: / 27.10.1997 / 18:55:48 / cg"
182
2ba5785a441e intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   339
! !
2ba5785a441e intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   340
2ba5785a441e intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   341
!SequenceableCollectionSorter class methodsFor:'documentation'!
2ba5785a441e intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   342
2ba5785a441e intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   343
version
4281
c0457c1b6e53 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   344
    ^ '$Header$'
182
2ba5785a441e intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   345
! !
4281
c0457c1b6e53 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   346
c0457c1b6e53 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   347
182
2ba5785a441e intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   348
SequenceableCollectionSorter initialize!