@@ -256,24 +256,36 @@ export class SortExecutor extends TransformExecutor {
256256 // displayed values to maintain their original types but
257257 // be sorted as if they were all strings.
258258 const stringifyIfNeeded = ( value : any ) => {
259- if ( typeof value != 'string' && columnDataType == 'string' ) {
259+ if ( typeof value != 'string' ) {
260260 return String ( value ) ;
261261 }
262262 return value ;
263263 } ;
264264
265- if ( this . _options . desc ) {
266- sortFunc = ( a : any , b : any ) : number => {
267- return stringifyIfNeeded ( a [ field ] ) < stringifyIfNeeded ( b [ field ] )
268- ? 1
269- : - 1 ;
270- } ;
265+ if ( columnDataType == 'string' ) {
266+ if ( this . _options . desc ) {
267+ sortFunc = ( a : any , b : any ) : number => {
268+ return stringifyIfNeeded ( a [ field ] ) < stringifyIfNeeded ( b [ field ] )
269+ ? 1
270+ : - 1 ;
271+ } ;
272+ } else {
273+ sortFunc = ( a : any , b : any ) : number => {
274+ return stringifyIfNeeded ( a [ field ] ) > stringifyIfNeeded ( b [ field ] )
275+ ? 1
276+ : - 1 ;
277+ } ;
278+ }
271279 } else {
272- sortFunc = ( a : any , b : any ) : number => {
273- return stringifyIfNeeded ( a [ field ] ) > stringifyIfNeeded ( b [ field ] )
274- ? 1
275- : - 1 ;
276- } ;
280+ if ( this . _options . desc ) {
281+ sortFunc = ( a : any , b : any ) : number => {
282+ return a [ field ] < b [ field ] ? 1 : - 1 ;
283+ } ;
284+ } else {
285+ sortFunc = ( a : any , b : any ) : number => {
286+ return a [ field ] > b [ field ] ? 1 : - 1 ;
287+ } ;
288+ }
277289 }
278290
279291 const data = input . data . slice ( 0 ) ;
0 commit comments