NLSSORT returns the string of bytes used to sort a text string. You can use this function to specify sorting and comparison operations based on a linguistic sort sequence rather than on the binary value of a string.

Note: NLSSORT returns a RAW value, which you may pass to another function. To create a measure or a calculated measure for the values returned by NLSSORT, use the RAWTOHEX function.

For more information about linguistic sorting, refer to the Oracle Database Globalization Support Guide.

Return Value



NLSSORT(char [, 'nlsparam' ])


char is a text expression.

nlsparam is a linguistic sort sequence in the form NLS_SORT =sort[_ai |_ci], where sort is an NLS language. You can add a suffix to the language to modify the sort: _ai for an accent-insensitive sort, or _ci for a case-insensitive sort.


NLSSORT('Rumpelstiltskin') returns the value 52756D70656C7374696C74736B696E00 for a default linguistic sort, which in this case is American.