Hi Blessing, Would be fun if you could use collations for this purpose, but I don’t think MarkLogic has one that does what you want. Your best bet would be to pre-compute a sorting key, and add that to the content. Once that is in place, sorting and such will be straight-forward..
Cheers, Geert From: <general-boun...@developer.marklogic.com<mailto:general-boun...@developer.marklogic.com>> on behalf of Blessing N <blessing...@gmail.com<mailto:blessing...@gmail.com>> Reply-To: MarkLogic Developer Discussion <general@developer.marklogic.com<mailto:general@developer.marklogic.com>> Date: Thursday, November 3, 2016 at 10:17 AM To: MarkLogic Developer Discussion <general@developer.marklogic.com<mailto:general@developer.marklogic.com>> Subject: [MarkLogic Dev General] Sorting Alphabets before Numbers Hi Team, Is there a way to sort alphabets before numbers. By default, letters have a larger value than numbers which places them last in a sorted list, but I wanted to list alphabets before number in an ascending sort. I found no collation which can achieve this but came up with the following work around which works as expected let $items := ('absence','beautiful','life','360 Degree Feedback','1', '10', '2', '11') for $i in $items order by if (fn:matches($i,'^[a-z]')) then fn:concat("1",$i) else fn:concat("2",$i) ascending return $i Unfortunately the application uses search:search (with pagination) and operates upon a huge data set. Therefore I'm facing two issues 1. Unable to apply this custom sort method to search:search 2. If the above workaround is used with cts:search then there is an impact on performance Is there a more optimized way to achieve this requirement? Thanks, Blessing.
_______________________________________________ General mailing list General@developer.marklogic.com Manage your subscription at: http://developer.marklogic.com/mailman/listinfo/general