Skip to content

Commit

Permalink
Unify the order_by examples.
Browse files Browse the repository at this point in the history
  • Loading branch information
jdunkerley committed Aug 16, 2022
1 parent 17b0438 commit 00573ab
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 13 deletions.
17 changes: 6 additions & 11 deletions distribution/lib/Standard/Database/0.0.0-dev/src/Data/Table.enso
Original file line number Diff line number Diff line change
Expand Up @@ -472,17 +472,6 @@ type Table

Missing (`Nothing`) values are sorted as less than any other object.

> Example
Order the table by the column "alpha" in ascending order.

table.order_by (Sort_Column_Selector.By_Name ["alpha"])

> Example
Order the table by the second column in ascending order. In case of any
ties, break them based on the 7th column from the end of the table in
descending order.

table.order_by (Sort_Column_Selector.By_Index [1, Sort_Column.Index -7 Sort_Direction.Descending])
> Example
Sorting `table` in ascending order by the value in column `'Quantity'`.

Expand All @@ -505,6 +494,12 @@ type Table
ties.

table.order_by (Sort_Column_Selector.By_Name [Sort_Column.Name 'Quantity', Sort_Column.Name 'Rating' Sort_Direction.Descending])
> Example
Order the table by the second column in ascending order. In case of any
ties, break them based on the 7th column from the end of the table in
descending order.

table.order_by (Sort_Column_Selector.By_Index [1, Sort_Column.Index -7 Sort_Direction.Descending])
order_by : Sort_Column_Selector -> Text_Ordering -> Problem_Behavior -> Table
order_by self (columns = (Sort_Column_Selector.By_Name [(Sort_Column.Name (self.columns.at 0 . name))])) text_ordering=Text_Ordering on_problems=Report_Warning = Panic.handle_wrapped_dataflow_error <|
problem_builder = Problem_Builder.new
Expand Down
23 changes: 21 additions & 2 deletions distribution/lib/Standard/Table/0.0.0-dev/src/Data/Table.enso
Original file line number Diff line number Diff line change
Expand Up @@ -560,16 +560,35 @@ type Table
`Incomparable_Values_Error`.

> Example
Order the table by the column "alpha" in ascending order.
Sorting `table` in ascending order by the value in column `'Quantity'`.

table.order_by (Sort_Column_Selector.By_Name ["alpha"])
table.order_by (Sort_Column_Selector.By_Name ['Quantity'])

> Example
Sorting `table` in descending order by the value in column `'Quantity'`.

table.order_by (Sort_Column_Selector.By_Name [Sort_Column.Name 'Quantity' Sort_Direction.Descending])

> Example
Sorting `table` in ascending order by the value in column `'Quantity'`,
using the value in column `'Rating'` for breaking ties.

table.order_by (Sort_Column_Selector.By_Name ['Quantity', 'Rating'])

> Example
Sorting `table` in ascending order by the value in column `'Quantity'`,
using the value in column `'Rating'` in descending order for breaking
ties.

table.order_by (Sort_Column_Selector.By_Name [Sort_Column.Name 'Quantity', Sort_Column.Name 'Rating' Sort_Direction.Descending])

> Example
Order the table by the second column in ascending order. In case of any
ties, break them based on the 7th column from the end of the table in
descending order.

table.order_by (Sort_Column_Selector.By_Index [1, Sort_Column.Index -7 Sort_Direction.Descending])

> Example
Sorting the shop inventory based on the per-item price in ascending
order.
Expand Down

0 comments on commit 00573ab

Please sign in to comment.