*/\r
\r
package third_parties.daveKoeller;\r
+import java.text.Collator;\r
import java.util.Comparator;\r
\r
import com.owncloud.android.datamodel.OCFile;\r
}\r
\r
/** Length of string is passed in for improved efficiency (only need to calculate it once) **/\r
- private final String getChunk(String s, int slength, int marker)\r
- {\r
+ private final String getChunk(String s, int slength, int marker){\r
StringBuilder chunk = new StringBuilder();\r
char c = s.charAt(marker);\r
chunk.append(c);\r
marker++;\r
- if (isDigit(c))\r
- {\r
+ if (isDigit(c)){\r
while (marker < slength)\r
{\r
c = s.charAt(marker);\r
chunk.append(c);\r
marker++;\r
}\r
- } else\r
- {\r
+ } else {\r
while (marker < slength)\r
{\r
c = s.charAt(marker);\r
return chunk.toString();\r
}\r
\r
- public int compare(OCFile o1, OCFile o2)\r
- {\r
+ public int compare(OCFile o1, OCFile o2){\r
String s1 = (String)o1.getRemotePath().toLowerCase();\r
String s2 = (String)o2.getRemotePath().toLowerCase();\r
\r
int s1Length = s1.length();\r
int s2Length = s2.length();\r
\r
- while (thisMarker < s1Length && thatMarker < s2Length)\r
- {\r
+ while (thisMarker < s1Length && thatMarker < s2Length) {\r
String thisChunk = getChunk(s1, s1Length, thisMarker);\r
thisMarker += thisChunk.length();\r
\r
\r
// If both chunks contain numeric characters, sort them numerically\r
int result = 0;\r
- if (isDigit(thisChunk.charAt(0)) && isDigit(thatChunk.charAt(0)))\r
- {\r
+ if (isDigit(thisChunk.charAt(0)) && isDigit(thatChunk.charAt(0))) {\r
// Simple chunk comparison by length.\r
int thisChunkLength = thisChunk.length();\r
result = thisChunkLength - thatChunk.length();\r
// If equal, the first different number counts\r
- if (result == 0)\r
- {\r
- for (int i = 0; i < thisChunkLength; i++)\r
- {\r
+ if (result == 0) {\r
+ for (int i = 0; i < thisChunkLength; i++) {\r
result = thisChunk.charAt(i) - thatChunk.charAt(i);\r
- if (result != 0)\r
- {\r
+ if (result != 0) {\r
return result;\r
}\r
}\r
}\r
- } else\r
- {\r
- result = thisChunk.compareTo(thatChunk);\r
+ } else {\r
+ Collator collator = Collator.getInstance();\r
+ collator.setStrength(Collator.PRIMARY);\r
+ result = collator.compare(thisChunk, thatChunk);\r
+// result = thisChunk.compareTo(thatChunk);\r
}\r
\r
if (result != 0)\r