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