Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9202023
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T23:09:39+00:00 2026-06-17T23:09:39+00:00

I have 5 numpy arrays within a single nxm array, with each array containing

  • 0

I have 5 numpy arrays within a single nxm array, with each array containing a set of random values. What I need is to print them according to their decreasing cumulative sums. For instance, my nXm array looks like:

 v = [[1,2,3,4], [2,3,4,5], [11,21,3,4], [4,33,21,1], [2,4,6,5]]

and what I need it to be ordered like is: the one having the highest cumulative sum comes first. I tried printing them according to argmax but it sneaks into all the elements of individual arrays and sorts them in a descending order..

Is there a way?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T23:09:41+00:00Added an answer on June 17, 2026 at 11:09 pm

    Assuming that by cumulative sum you mean total (there’s a cumulative sum function which returns something else), then you can do this both using the standard sort:

    >>> v = [[1,2,3,4], [2,3,4,5], [11,21,3,4], [4,33,21,1], [2,4,6,5]]
    >>> sorted(v, key=sum, reverse=True)
    [[4, 33, 21, 1], [11, 21, 3, 4], [2, 4, 6, 5], [2, 3, 4, 5], [1, 2, 3, 4]]
    

    and in numpy using argsort:

    >>> a = np.array(v)
    >>> a.sum(axis=1)
    array([10, 14, 39, 59, 17])
    >>> a.sum(axis=1).argsort()
    array([0, 1, 4, 2, 3])
    >>> a[a.sum(axis=1).argsort()[::-1]]
    array([[ 4, 33, 21,  1],
           [11, 21,  3,  4],
           [ 2,  4,  6,  5],
           [ 2,  3,  4,  5],
           [ 1,  2,  3,  4]])
    

    But I may be misunderstanding you.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a numpy array like this: x = np.array([[1,2,3],[4,5,6],[7,8,9]]) I need to create
I have a numpy array with positive and negative values in. a = array([1,1,-1,-2,-3,4,5])
I have a dictionary whose keys are strings and values are numpy arrays, e.g.:
I have 2 numpy arrays. One is a 2*2 array. a = [[1,2],[3,4]] The
I have a numpy object array containing several lists of index numbers: >>> idxLsts
I have a bunch of numpy arrays as attributes of an array of python
I have two numpy arrays X and W each with shape (N,N) that result
I have four numpy arrays like: X1 = array([[1, 2], [2, 0]]) X2 =
I have two ordered numpy arrays and I want to interleave them so that
I have some board numpy arrays like that: array([[0, 0, 0, 1, 0, 0,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.