Skip to main content

sortBy

sortBy

Sorts a DataSet list by one or more sort conditions. Use it when you need multi-column sorting.

Parameters

  • dmName (String): The DataSet name (DM name)
  • jsonData (object or array): A sort condition object, or an array of them. Fields of each condition:
    • fieldPath (string, required): The field path to sort by (e.g. "list.price")
    • order (string): "ascending" / "descending" / "origin". Defaults to "ascending"
    • isNumber (boolean): Whether to compare as numbers. Defaults to false
    • attrPath (string, optional): An alternate sort attribute path

Returns: None (void)

Description

sortString and sortNumber sort a single column only; sortBy accepts an array of conditions, which enables multi-key sorting. Conditions are applied in array order.

Example

// 단일 조건
$vm.sortBy("stock", { "fieldPath": "list.price", "order": "descending", "isNumber": true });

// 다중 조건 — 가격 내림차순, 동일 가격이면 이름 오름차순
$vm.sortBy("stock", [
{ "fieldPath": "list.price", "order": "descending", "isNumber": true },
{ "fieldPath": "list.name", "order": "ascending" }
]);

Related

  • $vm.sortString(dmName, responseKey, asc) — single-column string sort
  • $vm.sortNumber(dmName, responseKey, asc, attrPath) — single-column numeric sort