BF [ 1672820 ] Sorting should be language-sensitive

http://sourceforge.net/tracker/index.php?func=detail&aid=1672820&group_id=176962&atid=879332
This commit is contained in:
teo_sarca 2007-03-30 17:20:49 +00:00
parent 8e244d6190
commit 6720dfbf02
1 changed files with 8 additions and 3 deletions

View File

@ -19,6 +19,7 @@ package org.compiere.util;
import java.io.Serializable;
import java.math.BigDecimal;
import java.sql.Timestamp;
import java.text.Collator;
import java.util.Comparator;
/**
@ -45,6 +46,8 @@ public final class MSort implements Comparator, Serializable
{
index = new_index;
data = new_data;
// Create string collator for login language - teo_sarca, [ 1672820 ]
m_collator = Collator.getInstance(Language.getLoginLanguage().getLocale());
} // MSort
/** Direct access index */
@ -55,6 +58,9 @@ public final class MSort implements Comparator, Serializable
/** Multiplier */
private int m_multiplier = 1; // Asc by default
/** String Collator */
private Collator m_collator = null;
/**
* Sort Ascending
* @param ascending if true sort ascending
@ -106,8 +112,7 @@ public final class MSort implements Comparator, Serializable
// String
if (cmp1 instanceof String && cmp2 instanceof String)
{
String s = (String)cmp1;
return s.compareToIgnoreCase((String)cmp2) * m_multiplier;
return m_collator.compare(cmp1, cmp2) * m_multiplier; // teo_sarca [ 1672820 ]
}
// Date
else if (cmp1 instanceof Timestamp && cmp2 instanceof Timestamp)
@ -136,7 +141,7 @@ public final class MSort implements Comparator, Serializable
// Convert to string value
String s = cmp1.toString();
return s.compareToIgnoreCase(cmp2.toString()) * m_multiplier;
return m_collator.compare(s, cmp2.toString()) * m_multiplier; // teo_sarca [ 1672820 ]
} // compare
/**