We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. (Last updated on: June 24, 2019).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Custom Sorting - Ascending and descending

Thread ID:

Created:

Updated:

Platform:

Replies:

148401 Oct 17,2019 07:19 PM UTC Oct 21,2019 12:20 PM UTC ASP.NET MVC - EJ 2 3
loading
Tags: Grid
Matias Puzanowski
Asked On October 17, 2019 07:19 PM UTC

Hello Syncfustion Team!

I implemented a custom sort comparer for a date column with dd/MM/yyyy format, and is working perfectly for descending order, but how can I implement ascending order?

function sortDateComparer(a, b) {
    a = new Date(a);
    b = new Date(b);
    return a > b ? -1 : a < b ? 1 : 0;
 
}

Thanks in advance.

Pavithra Subramaniyam [Syncfusion]
Replied On October 18, 2019 10:13 AM UTC

Hi Matias, 

Thanks for contacting Syncfusion support. 

We have validated the provided code example and We suggest you to use the below way to achieve your requirement. 

function sortDateComparer(a, b) { 
  a = new Date(a); 
  b = new Date(b); 
  return a > b ? 1 : a < b ? -1 : 0; 
} 
 



Note: If a is less than b return -1 if a greater than b then return 1  
 
Regards, 
Pavithra S. 


Matias Puzanowski
Replied On October 18, 2019 12:43 PM UTC

Thanks a lot for replying and also for providing documentation, but I think that we misunderstood. Sort is working, but only in one way. 

Normal (ordered by IDs):



Descending (ordered perfectly):


Ascending (ordered just as descending):



So how can I do to sort in both ways?

Thanks in advance.







Pavithra Subramaniyam [Syncfusion]
Replied On October 21, 2019 12:20 PM UTC

Hi Matias, 

Thanks for your update. 

We have validated the provided information and checked with our end but we could not face the reported problem, both ascending and descending working fine at our sample. Please refer the below sample for more information. 


[Ascending result] 
 

[Descending] 
 

Could you please share more details or below information that will be more helpful for us to validate further at our end. 

  • Do you want to perform multiple sorting in Grid?
  • Share the full code example and package version details.
  • Share the video demo of your issue
  • If possible share the sample or reproduce the reported problem at our end

Regards, 
Pavithra S. 


CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Please sign in to access our forum

This page will automatically be redirected to the sign-in page in 10 seconds.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

Live Chat Icon For mobile
Live Chat Icon