Sort numbers lexicographically
Given an integer n, return 1 - n in lexicographical order.
For example, given 13, return: [1,10,11,12,13,2,3,4,5,6,7,8,9].
Ring
Sort numbers lexicographically is a draft programming task. It is not yet considered ready to be promoted as a complete task, for reasons that should be found in its talk page.
<lang ring>
- Project : Lexicographical numbers
- Date : 2018/07/25
- Author : Gal Zsolt (~ CalmoSoft ~)
- Email : <calmosoft@gmail.com>
lex = 1:13 strlex = list(len(lex)) for n = 1 to len(lex)
strlex[n] = string(lex[n])
next strlex = sort(strlex) see "Lexicographical numbers = " showarray(strlex)
func showarray(vect)
see "[" svect = "" for n = 1 to len(vect) svect = svect + vect[n] + "," next svect = left(svect, len(svect) - 1) see svect + "]" + nl
</lang> Output:
Lexicographical numbers = [1,10,11,12,13,2,3,4,5,6,7,8,9]