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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T20:05:00+00:00 2026-05-28T20:05:00+00:00

I’m trying to find out why I do get these strange results from this

  • 0

I’m trying to find out why I do get these strange results from this sort query:

redis> sort set:package:1:all_games by hash:game:*->rating DESC LIMIT 0 10 GET hash:game:*->rating
1. "10"
2. "10"
3. "10"
4. "9,1"
5. "9"
6. "9,2"
7. "9"
8. "9,1"
9. "9"
10. "9,4"
redis> 

I know the data uses , in stead of . and it will be fixed. But why is it sorted so inconsistently? I’d at least expect it to give consistent results (The 9,1’s in sequence).

Can anyone explain what’s going on here?

  • 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-28T20:05:02+00:00Added an answer on May 28, 2026 at 8:05 pm

    As mentioned by Ofer, by default, the sort is numeric and the elements are compared as double precision floating point numbers.

    Redis sort function works by populating a C array from the original container. The initial order of the items in this array is the order of the items in the initial container (which is undefined for set for instance).

    Each item is then tagged with a score value. Redis uses the standard strtod function to convert the string value to a double. This function works with a best effort approach: it tries to convert as many characters as possible. So the “9”, “9,1” “9,2” and “9,4” strings will all be converted to 9.0

    Finally the array is sorted using either the standard qsort algorithm, either the BENTLEY/McILROY algorithm (depending if limit parameters are set or not). AFAIK, none of these sort algorithms are stable. It means the order of the items with the same score will be random in the result.

    This is exactly what you get on the example: you have the “10” items first, and then the “9” items. Order of the “9” items is random.

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

Sidebar

Related Questions

I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
For some reason, after submitting a string like this Jack’s Spindle from a text
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
Does anyone know how can I replace this 2 symbol below from the string
I know there's a lot of other questions out there that deal with this
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
link Im having trouble converting the html entites into html characters, (&# 8217;) i
this is what i have right now Drawing an RSS feed into the php,

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.