Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
300
Custom comparer on multiple columns
posted

I have field Songname, which can be A, B or C, and field TrackNumber that can be -5 to 5. Now I want to sort as follows:

  • The primary sort depends on both fields. It sorts by ascending order of name if the track number is positive, and descending order of name if the track number is negative. So (A, 2) < (B, 2), but  (A, -2) > (B, -2). 
  • If the rows are equivalent by the first sorting criterion, then they are compared based on the value of the track number, so -3 < -1 < 2.

Now I see its possible to apply a custom comparer on a single field, or apply simple sorting on multiple columns, but what I need to do is create a comparer that receives the entire record object (or at least these two fields), and then sorts based on the combined value of the two fields. How do I do this?

Thanks 

Parents
No Data
Reply
  • 27093
    posted

    Hello,

    I am just checking the progress of this issue and was wondering if you managed to achieve your goal or if you need any further assistance on the matter.

    If the above suggestion helped you solve your issue please verify the thread as answered so other users may take better advantage of it.

Children
No Data