How To Sort Objects On Multiple Fields Using Comparator Interface

Поділитися
Вставка
  • Опубліковано 17 січ 2025

КОМЕНТАРІ • 23

  • @solomonstevens3907
    @solomonstevens3907 7 років тому +1

    This was a perfect explanation of a very specific question. Thanks!

  • @manaschaudhary2705
    @manaschaudhary2705 Рік тому

    simple and good explanation

  • @kuch0nahin
    @kuch0nahin 3 роки тому

    Great Explanation!

  • @tectej
    @tectej Рік тому

    Good tutorial

  • @Rajnish089
    @Rajnish089 3 роки тому

    This is a awesome viedo everytime i go for interview I watch this viedo

  • @prabhakarkanti9809
    @prabhakarkanti9809 6 років тому

    Way of teaching is very good ....very easy and simple thanks

  • @yforyou1342
    @yforyou1342 4 роки тому

    Thankyou, my issue got resolved from this logic.

  • @csquaredgaming
    @csquaredgaming 3 роки тому

    Whoa this is a lot simpler than the method I had found, though slightly less flexible. I think I'll use this way of sorting on multiple fields in the future for a lot of 'one-time' sorting jobs where I don't necessarily need to sort the data in a lot of different ways.

  • @krishnamohan5771
    @krishnamohan5771 9 місяців тому

    thank you sir.great health to you

  • @balajikoc1429
    @balajikoc1429 4 роки тому

    sorting on two fields, great explanation sir. Thank you.

  • @manikantthakur8519
    @manikantthakur8519 6 років тому

    You are a good teacher . Thanks it is very helpful

  • @sudhirpandey8124
    @sudhirpandey8124 7 років тому

    Awesome explanation. Thank you Sir.

  • @beps4440
    @beps4440 6 років тому

    Very helpful thanks a lot

  • @nitindixit676
    @nitindixit676 Рік тому

    Thanks for video/ I have an issue with this way of sorting though. Because, when the first field is sorted , second one is ignored/ For ex suppose there are two fields Age and name , & i intend to sort on age and name both. So if there are two entries with age 34, and name as Abhi and Nutan, I need Abhi to appear first in the list and then Nutan. How do I achieve this?

  • @rajukanuri8660
    @rajukanuri8660 3 роки тому +1

    Excellent explanation. Adding to your video.. we can do something like below in java8 with multiple fields:
    listOfEmps.stream().sorted(Comparator.comparing(Employee::getEmpId).thenComparing(Employee::getEmpName)).forEach(System.out::println);

  • @bushari7669
    @bushari7669 7 років тому +1

    Very helpful, thank you. Can you do a video on how to sort data in a CSV file?

    • @javamadeeasy2466
      @javamadeeasy2466  7 років тому

      Thanks Bushari. Yes I will make a video for this next.

  • @MrAsgar123
    @MrAsgar123 4 роки тому

    Thank you for your explanation, but you had sorted department only not name... can we sort both name, department together.

  • @ghgfds4228
    @ghgfds4228 4 роки тому

    thanks a lot...

  • @xF22Raptorx
    @xF22Raptorx 5 років тому

    THANK YOU!!!!!!!

  • @1msubscribers214
    @1msubscribers214 6 років тому

    Hi ,
    Hashmap have a key as orgid and value as emplist
    Ex:
    Map
    Employee class have empid ,empsalary
    Need to sort the hash map based on emp salary ??? Is it possible .. can u please explain the same with code ..
    Thanks,
    Karthic Sakthivel

  • @RicardoMedinaRojas
    @RicardoMedinaRojas 5 років тому

    Excellent !!! Quite accurate !