Ascending and descending sort¶
Syntax¶
_h2oframe sort [+|-]columnname [[+|-]columnname ...]
Description¶
_h2oframe sort arranges observations in ascending or descending order of the specified columns.
Each columnname must be a nonstring type. Read What is an H2O frame? for more information about the data types in an H2O frame. Note that if columnname is an enum column, this column only sorts in ascending order.
The observations are placed in ascending order of columnname if + or nothing is typed in front of the name and are placed in descending order if - is typed.
Examples¶
Setup
. sysuse auto
. _h2oframe put, into(auto)
. _h2oframe change auto
Place observations in ascending order of price
. _h2oframe sort price
Same as above command
. _h2oframe sort +price
List the result
. _h2oframe list make price
Place observations in descending order of price
. _h2oframe sort -price
List the result
. _h2oframe list make price
-----------------------------------------------------------------------------------
Setup
. webuse bp3
. _h2oframe put, into(bp3)
. _h2oframe change bp3
Place observations in ascending order of bp within ascending order of id
. _h2oframe sort id bp
List the result
. _h2oframe list id bp
Place observations in descending order of bp within ascending order of id
. _h2oframe sort id -bp
List the result
. _h2oframe list id bp