How to sort sum digits from the following list [closed]










-6















list1 = [1236,985,150,641876,167]


I want to know how to sorted by sum digits or sorted by last digit in Python.



Output sorted by sum of digits in ascending order:



[150,1236,167,985,641876]









share|improve this question















closed as unclear what you're asking by U9-Forward, James K Polk, RoadRunner, eyllanesc, Sandeep Kadapa Nov 12 '18 at 5:01


Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.













  • 2





    Unclear what you're asking, and way too broad, for noting.

    – U9-Forward
    Nov 12 '18 at 4:54












  • So....What output are you expecting here? Where is your attempt? Please provide an MCVE.

    – RoadRunner
    Nov 12 '18 at 4:57












  • [output] Sorted by sum of digits in ascending order: [150,1236,167,985,641876]

    – Pluvialis Pulchritudo
    Nov 12 '18 at 4:58












  • @PluvialisPulchritudo Use sorted(list1, key = lambda x: sum([int(i) for i in str(x)]))

    – Sandeep Kadapa
    Nov 12 '18 at 5:08











  • Or sorted(list1, key = lambda x: sum(map(int,str(x))))

    – Sandeep Kadapa
    Nov 12 '18 at 5:10















-6















list1 = [1236,985,150,641876,167]


I want to know how to sorted by sum digits or sorted by last digit in Python.



Output sorted by sum of digits in ascending order:



[150,1236,167,985,641876]









share|improve this question















closed as unclear what you're asking by U9-Forward, James K Polk, RoadRunner, eyllanesc, Sandeep Kadapa Nov 12 '18 at 5:01


Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.













  • 2





    Unclear what you're asking, and way too broad, for noting.

    – U9-Forward
    Nov 12 '18 at 4:54












  • So....What output are you expecting here? Where is your attempt? Please provide an MCVE.

    – RoadRunner
    Nov 12 '18 at 4:57












  • [output] Sorted by sum of digits in ascending order: [150,1236,167,985,641876]

    – Pluvialis Pulchritudo
    Nov 12 '18 at 4:58












  • @PluvialisPulchritudo Use sorted(list1, key = lambda x: sum([int(i) for i in str(x)]))

    – Sandeep Kadapa
    Nov 12 '18 at 5:08











  • Or sorted(list1, key = lambda x: sum(map(int,str(x))))

    – Sandeep Kadapa
    Nov 12 '18 at 5:10













-6












-6








-6








list1 = [1236,985,150,641876,167]


I want to know how to sorted by sum digits or sorted by last digit in Python.



Output sorted by sum of digits in ascending order:



[150,1236,167,985,641876]









share|improve this question
















list1 = [1236,985,150,641876,167]


I want to know how to sorted by sum digits or sorted by last digit in Python.



Output sorted by sum of digits in ascending order:



[150,1236,167,985,641876]






python list sorting sum digits






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 12 '18 at 7:50









martineau

67.8k1089182




67.8k1089182










asked Nov 12 '18 at 4:54









Pluvialis PulchritudoPluvialis Pulchritudo

12




12




closed as unclear what you're asking by U9-Forward, James K Polk, RoadRunner, eyllanesc, Sandeep Kadapa Nov 12 '18 at 5:01


Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.









closed as unclear what you're asking by U9-Forward, James K Polk, RoadRunner, eyllanesc, Sandeep Kadapa Nov 12 '18 at 5:01


Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.









  • 2





    Unclear what you're asking, and way too broad, for noting.

    – U9-Forward
    Nov 12 '18 at 4:54












  • So....What output are you expecting here? Where is your attempt? Please provide an MCVE.

    – RoadRunner
    Nov 12 '18 at 4:57












  • [output] Sorted by sum of digits in ascending order: [150,1236,167,985,641876]

    – Pluvialis Pulchritudo
    Nov 12 '18 at 4:58












  • @PluvialisPulchritudo Use sorted(list1, key = lambda x: sum([int(i) for i in str(x)]))

    – Sandeep Kadapa
    Nov 12 '18 at 5:08











  • Or sorted(list1, key = lambda x: sum(map(int,str(x))))

    – Sandeep Kadapa
    Nov 12 '18 at 5:10












  • 2





    Unclear what you're asking, and way too broad, for noting.

    – U9-Forward
    Nov 12 '18 at 4:54












  • So....What output are you expecting here? Where is your attempt? Please provide an MCVE.

    – RoadRunner
    Nov 12 '18 at 4:57












  • [output] Sorted by sum of digits in ascending order: [150,1236,167,985,641876]

    – Pluvialis Pulchritudo
    Nov 12 '18 at 4:58












  • @PluvialisPulchritudo Use sorted(list1, key = lambda x: sum([int(i) for i in str(x)]))

    – Sandeep Kadapa
    Nov 12 '18 at 5:08











  • Or sorted(list1, key = lambda x: sum(map(int,str(x))))

    – Sandeep Kadapa
    Nov 12 '18 at 5:10







2




2





Unclear what you're asking, and way too broad, for noting.

– U9-Forward
Nov 12 '18 at 4:54






Unclear what you're asking, and way too broad, for noting.

– U9-Forward
Nov 12 '18 at 4:54














So....What output are you expecting here? Where is your attempt? Please provide an MCVE.

– RoadRunner
Nov 12 '18 at 4:57






So....What output are you expecting here? Where is your attempt? Please provide an MCVE.

– RoadRunner
Nov 12 '18 at 4:57














[output] Sorted by sum of digits in ascending order: [150,1236,167,985,641876]

– Pluvialis Pulchritudo
Nov 12 '18 at 4:58






[output] Sorted by sum of digits in ascending order: [150,1236,167,985,641876]

– Pluvialis Pulchritudo
Nov 12 '18 at 4:58














@PluvialisPulchritudo Use sorted(list1, key = lambda x: sum([int(i) for i in str(x)]))

– Sandeep Kadapa
Nov 12 '18 at 5:08





@PluvialisPulchritudo Use sorted(list1, key = lambda x: sum([int(i) for i in str(x)]))

– Sandeep Kadapa
Nov 12 '18 at 5:08













Or sorted(list1, key = lambda x: sum(map(int,str(x))))

– Sandeep Kadapa
Nov 12 '18 at 5:10





Or sorted(list1, key = lambda x: sum(map(int,str(x))))

– Sandeep Kadapa
Nov 12 '18 at 5:10












1 Answer
1






active

oldest

votes


















0














Sorting list items considering unit's place. You can try:



list1 = [1236,985,150,641876,167] 
sorted(list1, key=lambda n: n%10)
[150, 985, 1236, 641876, 167]





share|improve this answer





























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    0














    Sorting list items considering unit's place. You can try:



    list1 = [1236,985,150,641876,167] 
    sorted(list1, key=lambda n: n%10)
    [150, 985, 1236, 641876, 167]





    share|improve this answer



























      0














      Sorting list items considering unit's place. You can try:



      list1 = [1236,985,150,641876,167] 
      sorted(list1, key=lambda n: n%10)
      [150, 985, 1236, 641876, 167]





      share|improve this answer

























        0












        0








        0







        Sorting list items considering unit's place. You can try:



        list1 = [1236,985,150,641876,167] 
        sorted(list1, key=lambda n: n%10)
        [150, 985, 1236, 641876, 167]





        share|improve this answer













        Sorting list items considering unit's place. You can try:



        list1 = [1236,985,150,641876,167] 
        sorted(list1, key=lambda n: n%10)
        [150, 985, 1236, 641876, 167]






        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Nov 12 '18 at 4:58









        Harsha BHarsha B

        2,64421733




        2,64421733















            Popular posts from this blog

            𛂒𛀶,𛀽𛀑𛂀𛃧𛂓𛀙𛃆𛃑𛃷𛂟𛁡𛀢𛀟𛁤𛂽𛁕𛁪𛂟𛂯,𛁞𛂧𛀴𛁄𛁠𛁼𛂿𛀤 𛂘,𛁺𛂾𛃭𛃭𛃵𛀺,𛂣𛃍𛂖𛃶 𛀸𛃀𛂖𛁶𛁏𛁚 𛂢𛂞 𛁰𛂆𛀔,𛁸𛀽𛁓𛃋𛂇𛃧𛀧𛃣𛂐𛃇,𛂂𛃻𛃲𛁬𛃞𛀧𛃃𛀅 𛂭𛁠𛁡𛃇𛀷𛃓𛁥,𛁙𛁘𛁞𛃸𛁸𛃣𛁜,𛂛,𛃿,𛁯𛂘𛂌𛃛𛁱𛃌𛂈𛂇 𛁊𛃲,𛀕𛃴𛀜 𛀶𛂆𛀶𛃟𛂉𛀣,𛂐𛁞𛁾 𛁷𛂑𛁳𛂯𛀬𛃅,𛃶𛁼

            Edmonton

            Crossroads (UK TV series)