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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T01:08:13+00:00 2026-05-26T01:08:13+00:00

(I’m attaching both Solr and SQL as tags because I don’t know what to

  • 0

(I’m attaching both Solr and SQL as tags because I don’t know what to use in such situation. Maybe even something else)

Example:

Web application that must sort tasks based on Time and Price. The user has a slider that determines what’s more important (Time or Price).

It has to do a weighted sorting where the score of the result depends on the Price and the Time but it must be possible to change the coefficients when the user slides towards Time or respectively Price.

Example 2:

User is trying to find the right socks. Wondering between how green and how long they should be. Again there’s a slider between these two properties. If at the slider’s 50% the user cares about how green they are as much as how long they are. If the slider’s closer to the green end the user is more interested in how green the socks are but do want to be long as well.

I don’t know what software to use or how to achieve this.

  • 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-26T01:08:14+00:00Added an answer on May 26, 2026 at 1:08 am

    MS SQL SERVER answer…

    DECLARE
      @min_time    DATETIME,
      @max_time    DATETIME,
      @min_price   MONEY,
      @max_price   MONEY
    SELECT
      @min_time    = MIN(timestamp),
      @max_time    = MAX(timestamp),
      @min_price   = MIN(price),
      @max_price   = MAX(price)
    FROM
      yourTable
    
    SELECT
      *
    FROM
      yourTable
    ORDER BY
      (CAST(DATEDIFF(second, @min_time, timestamp) AS FLOAT) / CAST(DATEDIFF(second, @min_time, @max_time) AS FLOAT)) * @slider
      +
      (CAST(price - @min_price AS FLOAT) / CAST(@max_price - @min_price AS FLOAT)) * (1 - @slider)
    
    -- Where te slider value is anything between 0 and 1
    

    To make your sentiment work, I do the same calculation to both Time and Price – I convert them to a value from 0 to 1 (which I’ll call it’s positional weight).
    – 0.0 = Equal to the minimum value for that field
    – 0.5 = Exaclty half way between the min and max of that field
    – 1.0 = Equal to the maximum value for that field

    I then multiply the positional weight by the slider’s value (or 1-value), and add the two results together.

    When the slider is at 0 or 1, it’s simple; one positional weight is multipled by one, one positional weight is multiplied by zero. In other words, one positional weight is unchanged, and one positional weight is ignored.

    When the slider is at 0.5, half of each positional weight is added together.

    In the case where 99.999% of values are close together and there is one extreme outlier, this can cause that field to be unusually dominant, or the opposite. (Most positional weights are very close to either 0 or 1)

    As such, one option is to base the positional weight on the data order only. So, in the case of many values being close, but with one extreme outlier; the value in the middle of the list still gets given 0.5 as it’s positional weight. In short – Its position in the sequence is important, not it’s actual value.

    DECLARE
      @count       FLOAT
    SELECT
      @count       = CAST(COUNT(*) AS FLOAT)
    FROM
      yourTable
    
    WITH
      ordered_data
    AS
    (
    SELECT
      ROW_NUMBER() OVER (ORDER BY timestamp) AS time_id,
      ROW_NUMBER() OVER (ORDER BY price)     AS price_id,
      *
    FROM
      yourData
    )
    SELECT
      *
    FROM
      ordered_data
    ORDER BY
      (CAST(time_id AS FLOAT) / @count) * @slider
      +
      (CAST(price_id AS FLOAT) / @count) * (1 - @slider)
    

    Which is best, why, etc, starts to get statistical, and depends on exactly what you are trying to achieve. Maybe you could take the average of the two different positional weights, and use those? Hopefully this gives you something to work with though.

    Both answers force the positional weight to be a percentage. This is because TIME and PRICE can have vastly different scales. Making them percantages (0 to 1) forces them to be of the same scale. You may want to consider alternative mechanisms for choosing suitable scales, and these may be different for each field.

    Each answer works out the positional weight relative to a fixed point : the lowest item in the list. You may wish to choose other reference points such as the MEAN, MODE or MEDIAN. In doing so you will have a range of positional weights of (-x to +y), with x and y potentially being very different values. You may then choose to re-weight these to be (-1 to +1). This will require scaling them along a curve, and you’ll need to decide how to determine that curve.

    Each answer works out a ‘distance’ from a fixed reference point as being 0 to 1, or in the previous paragraph -1 to +1. This assumes that both TIME and PRICE are always equally important. But what if you’ve chosen only the expensive items, where the positional weight should always be closer to 1? You’d need a mechanism to scale against “all possible values” rather than “all present values”.

    You have a lot of choice here, and what choice is right or wrong is dependant on the functional requirement you set out. I do not believe that there is a universal Truth to find. Perhaps you need to create some examples and work out what you WANT to happen, and then work out HOW?

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

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
I am trying to understand how to use SyndicationItem to display feed which is
Basically, what I'm trying to create is a page of div tags, each has
I want use html5's new tag to play a wav file (currently only supported
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
Configuring TinyMCE to allow for tags, based on a customer requirement. My config is
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
Does anyone know how can I replace this 2 symbol below from the string
I'm trying to use string.replace('’','') to replace the dreaded weird single-quote character: ’ (aka
I am writing an app with both english and french support. The app requests

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.