File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -5157,6 +5157,29 @@ 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+
51605183{ #category : #tests }
51615184DataFrameTest >> testSortByRowNamesUsing [
51625185 " sorts by second letter of row name"
Original file line number Diff line number Diff line change @@ -2469,6 +2469,13 @@ DataFrame >> sortByAll: arrayOfColumnNames [
24692469 ^ self
24702470]
24712471
2472+ { #category : #sorting }
2473+ DataFrame >> sortByRowNames [
2474+ " Sorts the rows of the data frame based on the row names in ascending order"
2475+
2476+ self sortByRowNamesUsing: [ :a :b | a <= b ]
2477+ ]
2478+
24722479{ #category : #sorting }
24732480DataFrame >> sortByRowNamesUsing: aBlock [
24742481 " Sorts the rows of the data frame based on the row names using the given comparison block"
You can’t perform that action at this time.
0 commit comments