Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Sort lexicographically?

I am working on integrating with the Photobucket API and I came across this in their api docs:

"Sort the parameters by name lexographically [sic] (byte ordering, the standard sorting, not natural or case insensitive). If the parameters have the same name, then sort by the value."

What does that mean? How do I sort something lexicographically? byte ordering?

The rest of their docs have been ok so far, but (to me) it seems like this line bears further explanation. Unfortunately there was none to be had.

Anyway, I'm writing the application in Python (it'll eventually become a Django app) in case you want to recommend specific modules that will handle such sorting for me ^_^

like image 938
Jiaaro Avatar asked May 08 '09 16:05

Jiaaro


People also ask

How do you sort lexicographically?

Lexicographical ordering means dictionary order. For ex: In dictionary 'ado' comes after 'adieu' because 'o' comes after 'i' in English alphabetic system. This ordering is not based on length of the string, but on the occurrence of the smallest letter first.

What is lexicographic order example?

1. 2. in lexicographic order are 123, 132, 213, 231, 312, and 321. Lexicographic order is sometimes called dictionary order.

How do I arrange string in lexicographically?

Sorting a string array in Lexicographical Order (Dictionary Order) using two approaches: By using any sorting technique to sort array elements. By using sort() function present in Arrays class in util package in java.

How do you sort lexicographically in C++?

Approach: The idea is to sort the given array of strings using the inbuilt sort function using the below comparator function. The comparator function used to check if any string occurs as a substring in another string using compare() function in C++ then, it should arrange them in decreasing order of their length.


2 Answers

I think that here lexicographic is a "alias" for ascii sort?

Lexicographic          Natural  
z1.doc                  z1.doc    
z10.doc                 z2.doc    
z100.doc                z3.doc    
z101.doc                z4.doc    
z102.doc                z5.doc    
z11.doc                 z6.doc    
z12.doc                 z7.doc    
z13.doc                 z8.doc    
z14.doc                 z9.doc     
z15.doc                z10.doc    
z16.doc                z11.doc    
z17.doc                z12.doc    
z18.doc                z13.doc     
z19.doc                z14.doc     
z2.doc                 z15.doc    
z20.doc                z16.doc    
z3.doc                 z17.doc    
z4.doc                 z18.doc    
z5.doc                 z19.doc    
z6.doc                 z20.doc    
z7.doc                z100.doc    
z8.doc                z101.doc    
z9.doc                z102.doc    
like image 60
dfa Avatar answered Sep 18 '22 00:09

dfa


The word should be "lexicographic"

http://www.thefreedictionary.com/Lexicographic

Dictionary order. Using the letters as they appear in the strings.

As they suggest, don't fold upper- and lower-case together. Just use the Python built-in list.sort() method.

like image 35
S.Lott Avatar answered Sep 21 '22 00:09

S.Lott