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 8552749
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T14:29:40+00:00 2026-06-11T14:29:40+00:00

Ok i think i did this wrong. This is my current collection however I

  • 0

Ok i think i did this wrong.
This is my current collection however I need to order these by percentage.

array (
  '_id' => new MongoId("505006de36314b4b27000001"),
  'status' => 'pending',
  'store_id' => new MongoId("505006de36314b4b27000000"),
  'minspendone' => '50.00',
  'cashbackone' => '1.50',
  'percentageone'▼ => '0.03',
  'minspendtwo' => '100.00',
  'cashbacktwo' => '3.00',
  'percentagetwo' => '0.03',
  'minspendthree' => '',
  'cashbackthree' => '',
  'percentagethree' => '',
  'minspendfour' => '',
  'cashbackfour' => '',
  'percentagefour' => '',
)

so would I better of changing it to the following

array (
  '_id' => new MongoId("505006de36314b4b27000001"),
  'status' => 'pending',
  'store_id' => new MongoId("505006de36314b4b27000000"),
  'offers' => array( 
  'minspend' => '50.00',
  'cashback' => '1.50',
  'percentage' => '0.03'),
  array(
  'minspend' => '100.00',
  'cashback' => '3.00',
  'percentage' => '0.03'))
)

could someone please advise me.

  • 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-11T14:29:42+00:00Added an answer on June 11, 2026 at 2:29 pm

    Russell,

    If you wish to use the mongodb internal sort function you will need to split the array elements into separate documents.

    Mongodb sort works to set the order of whole documents returned, rather the return order of elements within documents.

    Hope that clarifies.

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

Sidebar

Related Questions

Think I have an integer array like this: a[0]=60; a[1]=321; a[2]=5; now I want
I was able to run Default.aspx but i think i am doing this wrong.
My terminal keep create and forking . I think i did something wrong in
Initially, I did this the wrong way: I used MySQL to copy the tables.
This is a simple question, but I think I always used the wrong way.
Last night I think I did something that hosed my rails development environment, and
My fellow programmers did not think to add timestamps to every tables of our
Think about doing this: import matplotlib.pyplot as plt plt.plot(x_A,y_A,'g--') plt.plot(x_B,y_B,'r-o') plt.show() How would you
Perhaps I am doing this wrong and suggestions on how to improve my code
maybe a very simple question, however I have no idea what I do wrong,

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.