@@ -236,15 +236,15 @@ DataSeries >> crossTabulateWith: aSeries [
236236 ifFalse: [ SizeMismatch signal ].
237237
238238 df := DataFrame withRows:
239- (self uniqueValues collect: [ :each1 |
240- aSeries uniqueValues collect: [ :each2 |
239+ (self uniqueValues sortIfPossible collect: [ :each1 |
240+ aSeries uniqueValues sortIfPossible collect: [ :each2 |
241241 (1 to: self size) inject: 0 into: [ :accum :i |
242242 (((self atIndex: i) = each1) and : ((aSeries atIndex: i) = each2))
243243 ifTrue: [ accum + 1 ]
244244 ifFalse: [ accum ] ] ] ]).
245245
246- df rowNames: self uniqueValues.
247- df columnNames: aSeries uniqueValues.
246+ df rowNames: self uniqueValues sortIfPossible .
247+ df columnNames: aSeries uniqueValues sortIfPossible .
248248 ^ df
249249]
250250
@@ -341,7 +341,7 @@ DataSeries >> groupBy: otherSeries aggregateUsing: aBlock as: aNewName [
341341 | groupMap |
342342 self size = otherSeries size ifFalse: [ SizeMismatch signal ].
343343
344- groupMap := (otherSeries uniqueValues collect: [ :e | e - > OrderedCollection new ]) asOrderedDictionary.
344+ groupMap := (otherSeries uniqueValues sortIfPossible collect: [ :e | e - > OrderedCollection new ]) asOrderedDictionary.
345345
346346 1 to: self size do: [ :index | (groupMap at: (otherSeries atIndex: index)) add: (self atIndex: index) ].
347347
@@ -382,7 +382,7 @@ DataSeries >> groupByUniqueValuesAndAggregateUsing: aBlock as: aNewName [
382382 " Group my values by unique values, aggregate them using aBlock, and answer a new DataSeries with theunique values as keys, aggregated values of myself as values, and aNewName as name"
383383
384384 | groupMap |
385- groupMap := (self uniqueValues collect: [ :e | e - > OrderedCollection new ]) asOrderedDictionary.
385+ groupMap := (self uniqueValues sortIfPossible collect: [ :e | e - > OrderedCollection new ]) asOrderedDictionary.
386386
387387 self do: [ :each | (groupMap at: each) add: each ].
388388
0 commit comments