+int wxDataViewModel::Compare( const wxDataViewItem &item1, const wxDataViewItem &item2 )
+{
+ wxVariant value1,value2;
+ GetValue( value1, item1, m_sortingColumn );
+ GetValue( value2, item2, m_sortingColumn );
+ if (value1.GetType() == wxT("string"))
+ {
+ wxString str1 = value1.GetString();
+ wxString str2 = value2.GetString();
+ return str1.Cmp( str2 );
+ }
+ if (value1.GetType() == wxT("long"))
+ {
+ long l1 = value1.GetLong();
+ long l2 = value2.GetLong();
+ return l1-l2;
+ }
+ if (value1.GetType() == wxT("double"))
+ {
+ double d1 = value1.GetDouble();
+ double d2 = value2.GetDouble();
+ if (d1 == d2) return 0;
+ if (d1 < d2) return 1;
+ return -1;
+ }
+ if (value1.GetType() == wxT("datetime"))
+ {
+ wxDateTime dt1 = value1.GetDateTime();
+ wxDateTime dt2 = value2.GetDateTime();
+ if (dt1.IsEqualTo(dt2)) return 0;
+ if (dt1.IsEarlierThan(dt2)) return 1;
+ return -1;
+ }
+
+ return 0;
+}
+