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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T03:05:38+00:00 2026-06-09T03:05:38+00:00

I have this fiddle which was based on the results from this question .

  • 0

I have this fiddle which was based on the results from this question. I am trying to extend this further so that I can add a secondary sort so that if total price is the same it then looks to the commission column and whoever has the highest commission will go on top where the total sale price is equal. Is this possible? I am also having trouble with getting the commision column to be 2 decimal places. I have tried doing

var commish = '.text((val.price / 3) + (val.sales*5))'; 

and in the results section.

$("<td></td>");commish.toFixed(2).appendTo($tr);

But this has not worked.

  • 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-09T03:05:42+00:00Added an answer on June 9, 2026 at 3:05 am

    Calculate the commission and store in the objects, so that you can use it both in the sorting and the display:

    d.commission = d.price / 3 + d.sales * 5;
    

    To sort on the commission secondary, check if the price is equal, and if it is return the comparison for the commission:

    data.sort(function(a,b) {
      return a.price == b.price ? b.commission - a.commission : b.price - a.price;
    });
    

    When you have the commission in the object, it’s easy to format it for display:

    $("<td></td>").text(val.commission.toFixed(2)).appendTo($tr);
    

    Demo: http://jsfiddle.net/Guffa/VNSam/9/

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

Sidebar

Related Questions

I have this fiddle http://jsfiddle.net/jdsans/38GFS/ which I was trying to workout but I could
I have created a fiddle to test this : http://jsfiddle.net/Ninjanoel/X6ShS/ which works fine :(
I have this fiddle : http://jsfiddle.net/XjeCf/1/ that works like I want and this one
i have a very conceptual question regarding jquery. i have this fiddle http://jsfiddle.net/zvCrN/ What
I have this fiddle which has an error --> http://jsfiddle.net/Osoascam/AkZZr/6/ (This is the version
I have this code http://jsfiddle.net/xNHKP/6/ (not working in the fiddle for some reason which
Take a look at this fiddle - I've got three divs which all have
I have this simple fiddle , which uses jQuery mobile, but it's not working.
So I have this fiddle which totally explains my issue. Working fiddle The JS
I have this fiddle: http://jsfiddle.net/yub2B/4/ HTML: <input type=text /> <input type=text /> <input type=text

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.