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