2 // System.Globalization.SortKey.cs
5 // Dick Porter (dick@ximian.com)
7 // (C) 2002 Ximian, Inc.
10 namespace System.Globalization {
13 public class SortKey {
15 private CompareOptions options;
19 /* Hide the .ctor() */
22 internal SortKey (int lcid, string source,
23 CompareOptions options)
30 public virtual byte[] KeyData
37 public virtual string OriginalString
44 public static int Compare(SortKey sortkey1, SortKey sortkey2)
47 throw new ArgumentNullException ("sortkey1");
50 throw new ArgumentNullException ("sortkey2");
53 byte[] keydata1=sortkey1.key;
54 byte[] keydata2=sortkey2.key;
56 if(keydata1.Length==0) {
57 if(keydata2.Length==0) {
63 int min_len=(keydata1.Length < keydata2.Length)?
64 keydata1.Length:keydata2.Length;
66 for(int i=0; i<min_len; i++) {
67 if(keydata1[i] > keydata2[i]) {
69 } else if(keydata1[i] < keydata2[i]) {
74 if(keydata1.Length < keydata2.Length) {
76 } else if (keydata1.Length > keydata2.Length) {
83 public override bool Equals(object value)
85 SortKey other=(value as SortKey);
87 if((this.lcid==other.lcid) &&
88 (this.options==other.options) &&
89 (Compare (this, other)==0)) {
97 public override int GetHashCode()
99 return(str.GetHashCode ());
102 public override string ToString()
104 return("SortKey - "+lcid+", "+options+", "+str);