Question

When declaring dependencies in Gradle I like to keep my dependencies in alphabetical order, however I have come across a situation when I am not sure what the correct order would be. Wikipedia states "Various conventions also exist for the handling of strings containing spaces, modified letters (such as those with diacritics), and non-letter characters such as marks of punctuation", however there is no reference to what these conventions might be.

Specifically I not sure what order I should list the dependencies below.

compile(group: 'commons-pool', name: 'commons-pool', version: '1.2')
compile(group: 'com.google.protobuf', name: 'protobuf-java', version: '2.0.3')

Is there a documented convention for handling lexicographical ordering of punctuation, and where can I find it?

Was it helpful?

Solution

Looking at ASCII values, '.' (ASCII 46) comes before 'm' (ASCII 109). This works for comparing basic punctuation to letters, however you should remember that in ASCII capital 'Z' comes before lowercase 'a'.

UTS #10: Unicode Collation Algorithm covers comparing strings that contain punctuation.

This report is the specification of the Unicode Collation Algorithm (UCA), which details how to compare two Unicode strings while remaining conformant to the requirements of the Unicode Standard. The UCA also supplies the Default Unicode Collation Element Table (DUCET) as the data specifying the default collation order for all Unicode characters.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top