@@ -5157,6 +5157,54 @@ DataFrameTest >> testSortByAll [
51575157 self assert: actual equals: expected
51585158]
51595159
5160+ { #category : #tests }
5161+ DataFrameTest >> testSortByRowNames [
5162+
5163+ | dataFrame expected sortedDF |
5164+ dataFrame := DataFrame withRows:
5165+ #( #( 'CD' 3 2 )
5166+ #( 'AC' 1 4 )
5167+ #( 'DB' 2 4 )
5168+ #( 'BA' 5 1 ) ).
5169+ dataFrame rowNames: #( 'CD' 'AC' 'DB' 'BA' ) .
5170+
5171+ expected := DataFrame withRows:
5172+ #( #( 'AC' 1 4 )
5173+ #( 'BA' 5 1 )
5174+ #( 'CD' 3 2 )
5175+ #( 'DB' 2 4 ) ).
5176+ expected rowNames: #( 'AC' 'BA' 'CD' 'DB' ) .
5177+
5178+ sortedDF := dataFrame sortByRowNames.
5179+
5180+ self assert: sortedDF equals: expected
5181+ ]
5182+
5183+ { #category : #tests }
5184+ DataFrameTest >> testSortByRowNamesUsing [
5185+ " sorts by second letter of row name"
5186+
5187+ | dataFrame expected sortedDF |
5188+ dataFrame := DataFrame withRows:
5189+ #( #( 'CD' 3 2 )
5190+ #( 'AC' 1 4 )
5191+ #( 'DB' 2 4 )
5192+ #( 'BA' 5 1 ) ).
5193+ dataFrame rowNames: #( 'CD' 'AC' 'DB' 'BA' ) .
5194+
5195+ expected := DataFrame withRows:
5196+ #( #( 'BA' 5 1 )
5197+ #( 'DB' 2 4 )
5198+ #( 'AC' 1 4 )
5199+ #( 'CD' 3 2 ) ).
5200+ expected rowNames: #( 'BA' 'DB' 'AC' 'CD' ) .
5201+
5202+ sortedDF := dataFrame sortByRowNamesUsing: [ :name1 :name2 |
5203+ name1 second <= name2 second ].
5204+
5205+ self assert: sortedDF equals: expected
5206+ ]
5207+
51605208{ #category : #tests }
51615209DataFrameTest >> testSortByUsing [
51625210 " Sort by second letter of city name"
@@ -5224,6 +5272,29 @@ DataFrameTest >> testSortDescendingByAll [
52245272 self assert: actual equals: expected
52255273]
52265274
5275+ { #category : #tests }
5276+ DataFrameTest >> testSortDescendingByRowNames [
5277+
5278+ | dataFrame expected sortedDF |
5279+ dataFrame := DataFrame withRows:
5280+ #( #( 'CD' 3 2 )
5281+ #( 'AC' 1 4 )
5282+ #( 'DB' 2 4 )
5283+ #( 'BA' 5 1 ) ).
5284+ dataFrame rowNames: #( 'CD' 'AC' 'DB' 'BA' ) .
5285+
5286+ expected := DataFrame withRows:
5287+ #( #( 'DB' 2 4 )
5288+ #( 'CD' 3 2 )
5289+ #( 'BA' 5 1 )
5290+ #( 'AC' 1 4 ) ).
5291+ expected rowNames: #( 'DB' 'CD' 'BA' 'AC' ) .
5292+
5293+ sortedDF := dataFrame sortDescendingByRowNames.
5294+
5295+ self assert: sortedDF equals: expected
5296+ ]
5297+
52275298{ #category : #tests }
52285299DataFrameTest >> testToColumnApplyElementwise [
52295300
0 commit comments