Thanks a lot Damon That's the best solution and I love this forum as we always get the best solutions and clarifications.
Regards, Gnana(GP) >> Gnana, The map is a hash map, so I assume the order of the elements is affected by how they get allocated to hash buckets. You could try this instead: let $x := (1,2,3,4,5, 9) ! xs:string(.) let $y := (2,3,6,7,9, 10, 11, 22, 101) ! xs:string(.) let $mx := map:map() let $add-all := for $i in $x return map:put($mx, xs:string($i), true()) return $y[map:get($mx, .)] You'll need to work a little harder if you really have numeric values because map keys have to be strings. Geert is right that if you can have the database directly return lexicon values, that can be easier. Most lexicon functions have an option now to return data as a map. Yours, Damon This e-mail and any files transmitted with it are for the sole use of the intended recipient(s) and may contain confidential and privileged information. If you are not the intended recipient(s), please reply to the sender and destroy all copies of the original message. Any unauthorized review, use, disclosure, dissemination, forwarding, printing or copying of this email, and/or any action taken in reliance on the contents of this e-mail is strictly prohibited and may be unlawful. _______________________________________________ General mailing list General@developer.marklogic.com http://developer.marklogic.com/mailman/listinfo/general