Thứ tự sắp xếp xác định cách sắp xếp các hàng trong phản hồi. Ví dụ: sắp xếp các hàng theo số sự kiện giảm dần là một thứ tự và sắp xếp các hàng theo chuỗi tên sự kiện là một thứ tự khác.
Biểu diễn dưới dạng JSON
{"desc": boolean,// Union field one_order_by can be only one of the following:"metric": {object (MetricOrderBy)},"dimension": {object (DimensionOrderBy)},"pivot": {object (PivotOrderBy)}// End of list of possible types for union field one_order_by.}
Trường
desc
boolean
Nếu đúng, hãy sắp xếp theo thứ tự giảm dần.
Trường hợp hợp nhất one_order_by. Chỉ định một loại thứ tự cho OrderBy. one_order_by chỉ có thể là một trong những giá trị sau:
Quy tắc sắp xếp các giá trị phương diện chuỗi theo.
Enum
ORDER_TYPE_UNSPECIFIED
Không xác định.
ALPHANUMERIC
Sắp xếp chữ và số theo điểm mã Unicode. Ví dụ: "2" < "A" < "X" < "b" < "z".
CASE_INSENSITIVE_ALPHANUMERIC
Sắp xếp kiểu chữ số và chữ cái không phân biệt chữ hoa chữ thường theo điểm mã Unicode viết thường. Ví dụ: "2" < "A" < "b" < "X" < "z".
NUMERIC
Giá trị phương diện được chuyển đổi thành số trước khi sắp xếp. Ví dụ: trong cách sắp xếp SỐ, "25" < "100" và trong cách sắp xếp ALPHANUMERIC, "100" < "25". Tất cả giá trị phương diện không phải số đều có giá trị thứ tự bằng nhau bên dưới tất cả giá trị số.
Dùng để chọn tên phương diện và tổng hợp giá trị. Nếu bạn chọn nhiều lựa chọn tổng hợp, thì việc sắp xếp sẽ diễn ra trên các hàng mà tất cả cặp giá trị và tên phương diện của lựa chọn tổng hợp đều khớp với cặp giá trị và tên phương diện của hàng.
PivotSelection
Một cặp tên và giá trị phương diện. Các hàng có cặp trục theo phương diện này được sắp xếp theo giá trị của chỉ số.
Ví dụ: nếu pivots = ('browser', 'Chrome') và metricName = "Sessions", thì các hàng sẽ được sắp xếp dựa trên Số phiên trong Chrome.
[[["Dễ hiểu","easyToUnderstand","thumb-up"],["Giúp tôi giải quyết được vấn đề","solvedMyProblem","thumb-up"],["Khác","otherUp","thumb-up"]],[["Thiếu thông tin tôi cần","missingTheInformationINeed","thumb-down"],["Quá phức tạp/quá nhiều bước","tooComplicatedTooManySteps","thumb-down"],["Đã lỗi thời","outOfDate","thumb-down"],["Vấn đề về bản dịch","translationIssue","thumb-down"],["Vấn đề về mẫu/mã","samplesCodeIssue","thumb-down"],["Khác","otherDown","thumb-down"]],["Cập nhật lần gần đây nhất: 2025-07-26 UTC."],[[["\u003cp\u003eOrderBys determine the sorting of rows in a response, based on metrics, dimensions, or pivots.\u003c/p\u003e\n"],["\u003cp\u003eYou can order by metrics (e.g., event count), dimensions (e.g., event name), or pivot column groups.\u003c/p\u003e\n"],["\u003cp\u003eSorting can be done in ascending or descending order, specified by the \u003ccode\u003edesc\u003c/code\u003e boolean field.\u003c/p\u003e\n"],["\u003cp\u003eDimension sorting offers alphanumeric, case-insensitive alphanumeric, and numeric order types.\u003c/p\u003e\n"],["\u003cp\u003ePivotOrderBy allows sorting within specific pivot column groups based on metric values.\u003c/p\u003e\n"]]],["This content details various methods for sorting data rows in a response, known as \"OrderBys.\" Sorting can be based on metrics (`MetricOrderBy`) or dimensions (`DimensionOrderBy`). Dimensions can be ordered alphanumerically, case-insensitively, or numerically (`OrderType`). `PivotOrderBy` allows sorting by metric values within pivot column groups, using `PivotSelection` to specify dimension-value pairs for focused sorting. `OrderBys` can also be applied in descending order, indicated by the `desc` field.\n"],null,["# OrderBy\n\n- [JSON representation](#SCHEMA_REPRESENTATION)\n- [MetricOrderBy](#MetricOrderBy)\n - [JSON representation](#MetricOrderBy.SCHEMA_REPRESENTATION)\n- [DimensionOrderBy](#DimensionOrderBy)\n - [JSON representation](#DimensionOrderBy.SCHEMA_REPRESENTATION)\n- [OrderType](#OrderType)\n- [PivotOrderBy](#PivotOrderBy)\n - [JSON representation](#PivotOrderBy.SCHEMA_REPRESENTATION)\n- [PivotSelection](#PivotSelection)\n - [JSON representation](#PivotSelection.SCHEMA_REPRESENTATION)\n\nOrder bys define how rows will be sorted in the response. For example, ordering rows by descending event count is one ordering, and ordering rows by the event name string is a different ordering.\n\n| JSON representation |\n|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| ``` { \"desc\": boolean, // Union field `one_order_by` can be only one of the following: \"metric\": { object (/analytics/devguides/reporting/data/v1/rest/v1beta/OrderBy#MetricOrderBy) }, \"dimension\": { object (/analytics/devguides/reporting/data/v1/rest/v1beta/OrderBy#DimensionOrderBy) }, \"pivot\": { object (/analytics/devguides/reporting/data/v1/rest/v1beta/OrderBy#PivotOrderBy) } // End of list of possible types for union field `one_order_by`. } ``` |\n\n| Fields ||\n|-------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| `desc` | `boolean` If true, sorts by descending order. |\n| Union field `one_order_by`. Specify one type of order by for `OrderBy`. `one_order_by` can be only one of the following: ||\n| `metric` | `object (`[MetricOrderBy](/analytics/devguides/reporting/data/v1/rest/v1beta/OrderBy#MetricOrderBy)`)` Sorts results by a metric's values. |\n| `dimension` | `object (`[DimensionOrderBy](/analytics/devguides/reporting/data/v1/rest/v1beta/OrderBy#DimensionOrderBy)`)` Sorts results by a dimension's values. |\n| `pivot` | `object (`[PivotOrderBy](/analytics/devguides/reporting/data/v1/rest/v1beta/OrderBy#PivotOrderBy)`)` Sorts results by a metric's values within a pivot column group. |\n\nMetricOrderBy\n-------------\n\nSorts by metric values.\n\n| JSON representation |\n|----------------------------------|\n| ``` { \"metricName\": string } ``` |\n\n| Fields ||\n|----------------|----------------------------------------------------|\n| `metric``Name` | `string` A metric name in the request to order by. |\n\nDimensionOrderBy\n----------------\n\nSorts by dimension values.\n\n| JSON representation |\n|-------------------------------------------------------------------------------------------------------------------------------|\n| ``` { \"dimensionName\": string, \"orderType\": enum (/analytics/devguides/reporting/data/v1/rest/v1beta/OrderBy#OrderType) } ``` |\n\n| Fields ||\n|-------------------|----------------------------------------------------------------------------------------------------------------------------------------------|\n| `dimension``Name` | `string` A dimension name in the request to order by. |\n| `order``Type` | `enum (`[OrderType](/analytics/devguides/reporting/data/v1/rest/v1beta/OrderBy#OrderType)`)` Controls the rule for dimension value ordering. |\n\nOrderType\n---------\n\nRule to order the string dimension values by.\n\n| Enums ||\n|---------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| `ORDER_TYPE_UNSPECIFIED` | Unspecified. |\n| `ALPHANUMERIC` | Alphanumeric sort by Unicode code point. For example, \"2\" \\\u003c \"A\" \\\u003c \"X\" \\\u003c \"b\" \\\u003c \"z\". |\n| `CASE_INSENSITIVE_ALPHANUMERIC` | Case insensitive alphanumeric sort by lower case Unicode code point. For example, \"2\" \\\u003c \"A\" \\\u003c \"b\" \\\u003c \"X\" \\\u003c \"z\". |\n| `NUMERIC` | Dimension values are converted to numbers before sorting. For example in NUMERIC sort, \"25\" \\\u003c \"100\", and in `ALPHANUMERIC` sort, \"100\" \\\u003c \"25\". Non-numeric dimension values all have equal ordering value below all numeric values. |\n\nPivotOrderBy\n------------\n\nSorts by a pivot column group.\n\n| JSON representation |\n|-------------------------------------------------------------------------------------------------------------------------------------------------|\n| ``` { \"metricName\": string, \"pivotSelections\": [ { object (/analytics/devguides/reporting/data/v1/rest/v1beta/OrderBy#PivotSelection) } ] } ``` |\n\n| Fields ||\n|-----------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| `metric``Name` | `string` In the response to order by, order rows by this column. Must be a metric name from the request. |\n| `pivot``Selections[]` | `object (`[PivotSelection](/analytics/devguides/reporting/data/v1/rest/v1beta/OrderBy#PivotSelection)`)` Used to select a dimension name and value pivot. If multiple pivot selections are given, the sort occurs on rows where all pivot selection dimension name and value pairs match the row's dimension name and value pair. |\n\nPivotSelection\n--------------\n\nA pair of dimension names and values. Rows with this dimension pivot pair are ordered by the metric's value.\n\nFor example if pivots = ('browser', 'Chrome') and metricName = \"Sessions\", then the rows will be sorted based on Sessions in Chrome. \n\n ---------|----------|----------------|----------|----------------\n | Chrome | Chrome | Safari | Safari\n ---------|----------|----------------|----------|----------------\n Country | Sessions | Pages/Sessions | Sessions | Pages/Sessions\n ---------|----------|----------------|----------|----------------\n US | 2 | 2 | 3 | 1\n ---------|----------|----------------|----------|----------------\n Canada | 3 | 1 | 4 | 1\n ---------|----------|----------------|----------|----------------\n\n| JSON representation |\n|---------------------------------------------------------------|\n| ``` { \"dimensionName\": string, \"dimensionValue\": string } ``` |\n\n| Fields ||\n|--------------------|----------------------------------------------------------------|\n| `dimension``Name` | `string` Must be a dimension name from the request. |\n| `dimension``Value` | `string` Order by only when the named dimension is this value. |"]]