diff --git a/docs/plugins/sort.rst b/docs/plugins/sort.rst index cc86b3ddd..12684175f 100644 --- a/docs/plugins/sort.rst +++ b/docs/plugins/sort.rst @@ -1,33 +1,51 @@ -sort-items -========== -Sort the visible item list:: - - sort-items order [order...] +sort +==== +Tags: +:dfhack-keybind:`sort-items` +:dfhack-keybind:`sort-units` -Sort the item list using the given sequence of comparisons. -The ``<`` prefix for an order makes undefined values sort first. -The ``>`` prefix reverses the sort order for defined values. +Sort the visible item or unit list. -Item order examples:: +Usage:: - description material wear type quality + sort-items [ ...] + sort-units [ ...] -The orderings are defined in ``hack/lua/plugins/sort/*.lua`` +Both commands sort the visible list using the given sequence of comparisons. +Each property can be prefixed with a ``<`` or ``>`` character to indicate +whether elements that don't have the given property defined go first or last +(respectively) in the sorted list. -sort-units -========== -Sort the visible unit list:: +Examples +-------- - sort-units order [order...] +``sort-items material type quality`` + Sort a list of items by material, then by type, then by quality +``sort-units profession name`` + Sort a list of units by profession, then by name -Sort the unit list using the given sequence of comparisons. -The ``<`` prefix for an order makes undefined values sort first. -The ``>`` prefix reverses the sort order for defined values. +Properties +---------- -Unit order examples:: +Items can be sorted by the following properties: - name age arrival squad squad_position profession +- ``type`` +- ``description`` +- ``base_quality`` +- ``quality`` +- ``improvement`` +- ``wear`` +- ``material`` -The orderings are defined in ``hack/lua/plugins/sort/*.lua`` +Units can be sorted by the following properties: -:dfhack-keybind:`sort-units` +- ``name`` +- ``age`` +- ``arrival`` +- ``noble`` +- ``profession`` +- ``profession_class`` +- ``race`` +- ``squad`` +- ``squad_position`` +- ``happiness`` diff --git a/plugins/sort.cpp b/plugins/sort.cpp index ab2829655..630ac9e53 100644 --- a/plugins/sort.cpp +++ b/plugins/sort.cpp @@ -56,25 +56,9 @@ static command_result sort_items(color_ostream &out, vector & parameter DFhackCExport command_result plugin_init (color_ostream &out, std::vector &commands) { commands.push_back(PluginCommand( - "sort-units", "Sort the visible unit list.", sort_units, unit_list_hotkey, - " sort-units order [order...]\n" - " Sort the unit list using the given sequence of comparisons.\n" - " The '<' prefix for an order makes undefined values sort first.\n" - " The '>' prefix reverses the sort order for defined values.\n" - " Unit order examples:\n" - " name, age, arrival, squad, squad_position, profession\n" - "The orderings are defined in hack/lua/plugins/sort/*.lua\n" - )); + "sort-units", "Sort the visible unit list.", sort_units, unit_list_hotkey)); commands.push_back(PluginCommand( - "sort-items", "Sort the visible item list.", sort_items, item_list_hotkey, - " sort-items order [order...]\n" - " Sort the item list using the given sequence of comparisons.\n" - " The '<' prefix for an order makes undefined values sort first.\n" - " The '>' prefix reverses the sort order for defined values.\n" - " Item order examples:\n" - " description, material, wear, type, quality\n" - "The orderings are defined in hack/lua/plugins/sort/*.lua\n" - )); + "sort-items", "Sort the visible item list.", sort_items, item_list_hotkey)); return CR_OK; }