Sorting Query for all type of value

Suppose I have a data given below:

ID
------------------------
106
J1002
206
XYZ300
1002
J206
XYZ1002

How to sort this type of data?

You use an ORDER BY clause in your query, naming the field you want things sorted by.

Or have you already done so, and aren’t getting things in the order you want? If so, what order would you prefer to see?

I have already use ORDER BY clause but it did not work actually

If the id is mixed data types collation order is based on data types also. i.e. first sorts based on data types then with in the data types.

https://docs.couchbase.com/server/6.0/n1ql/n1ql-language-reference/datatypes.html

Collation defines the sort order for data types. Here is the collation order used for N1QL data types:

  • MISSING
  • NULL
  • Boolean
  • number
  • string
  • array
  • object
  • binary (non-JSON)