Author: gs Date: Thu May 10 15:01:11 2012 New Revision: 68138 URL: http://svn.opensuse.org/viewcvs/yast?rev=68138&view=rev Log: improve table sorting Modified: trunk/ncurses/src/NCTablePad.h Modified: trunk/ncurses/src/NCTablePad.h URL: http://svn.opensuse.org/viewcvs/yast/trunk/ncurses/src/NCTablePad.h?rev=68138&r1=68137&r2=68138&view=diff ============================================================================== --- trunk/ncurses/src/NCTablePad.h (original) +++ trunk/ncurses/src/NCTablePad.h Thu May 10 15:01:11 2012 @@ -97,9 +97,29 @@ NCTableLine * second ) const { - return first->GetCol( _uiCol )->Label().getText().begin()->str() - < second->GetCol( _uiCol )->Label().getText().begin()->str(); + wstring w1 = first->GetCol( _uiCol )->Label().getText().begin()->str(); + wstring w2 = second->GetCol( _uiCol )->Label().getText().begin()->str(); + wchar_t *endptr = 0; + + long int number1 = std::wcstol( w1.data(), &endptr, 10 ); + long int number2 = std::wcstol( w2.data(), &endptr, 10 ); + + // both are numbers + if ( w1.data() != endptr && w2.data() != endptr ) + { + return number1 < number2; + } + else // compare strings + { + int result = std::wcscoll ( w1.data(), w2.data() ); + + if ( result <= 0 ) + return true; + else + return false; + } } + private: int _uiCol; }; -- To unsubscribe, e-mail: yast-commit+unsubscribe@opensuse.org For additional commands, e-mail: yast-commit+help@opensuse.org