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

  • Home
  • SEARCH
  • 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 6118957
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T15:29:48+00:00 2026-05-23T15:29:48+00:00

So if I had 2 columns in a object A -> values are 10

  • 0

So if I had 2 columns in a object

A -> values are 10 8 6 4

B -> values are 9 7 5 3

I want to merge B into A with 9 below 10, 7 below 8 etc.

uasort($TopConsumers,array('Utilities','orderconsumers'));
public static function orderConsumers($TopConsumers)
{
    $a = $TopConsumers->outTotal;
    $b = $TopConsumers->inTotal;
    if ($a == $b) {
        return 0;
    }
    return ($a > $b) ? -1 : +1;
}

Why is this not working?

  • 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-05-23T15:29:48+00:00Added an answer on May 23, 2026 at 3:29 pm

    Your sorting function needs to have $a and $b as arguments to it. Not the array itself.

    public static function orderConsumers($a, $b)
    {
        if ($a->outTotal == $b->inTotal) {
            return 0;
        }
        return ($a->outTotal > $b-inTotal) ? -1 : +1;
    }
    

    That said it seems a little odd to sort by two columns. I’m not sure this is going to give you what you’re looking for. Normally you’d compare the same column name in a user sort function like that.

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

Sidebar

Related Questions

We are in the process of encrypting all the SSN columns (had to do
Basically if I had a mysql table with columns: id, type, content, version. There
Hi I had parent table which has ID and some other columns and a
Is there a way I can control columns from code. I had a drop
When creating indexes for an SQL table,if i had an index on 2 columns
I added a FULLTEXT index on three of my columns, after I already had
i want to fill the data of the charts from values i have in
I have the following business object: public class MyObject { // Some public properties
I have an extension method to convert a DbDataReader to an IEnumerable object: public
I had a simple table: class test(Base): __tablename__ = 'test' id = Column(Integer, primary_key=True)

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.