Title: Sorting bug
Last modified: January 5, 2022

---

# Sorting bug

 *  Resolved [T_ed](https://wordpress.org/support/users/t_ed/)
 * (@t_ed)
 * [4 years, 5 months ago](https://wordpress.org/support/topic/sorting-bug-3/)
 * Hello.
    If you look at page that I need help with at almost bottom of the page,
   you will notice strange sorting behavior. That is how rating scores will be sorted
   like: 2.5 – 1.9 – **2.3** – 1.7 – 1.4 – **2** -1.3 I am using Elementor PRO posts
   widget with following snippet and “sorted_by_rank” querry ID:
 *     ```
       add_action('elementor/query/sorted_by_rank', function ($query) {
           $query->set('meta_query', [
               'relation' => 'OR',
               ['key' => '_glsr_average', 'compare' => 'NOT EXISTS'], // this comes first!
               ['key' => '_glsr_average', 'compare' => 'EXISTS'],
           ]);
           $query->set('orderby', 'meta_value_num');
           $query->set('order', 'DESC');
       });
       ```
   
 * So, for some posts sorting seemes to be broken.
    I have tried all repairing tools(
   Migrate, Reset Meta Values, Relations), that does not worked for me.
 * The page I need help with: _[[log in](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fwordpress.org%2Fsupport%2Ftopic%2Fsorting-bug-3%2F%3Foutput_format%3Dmd&locale=en_US)
   to see the link]_

Viewing 5 replies - 1 through 5 (of 5 total)

 *  Plugin Author [Gemini Labs](https://wordpress.org/support/users/geminilabs/)
 * (@geminilabs)
 * [4 years, 5 months ago](https://wordpress.org/support/topic/sorting-bug-3/#post-15221926)
 * Did you try clearing your page cache after using the “Reset Assigned Meta Values”
   tool?
 *  Thread Starter [T_ed](https://wordpress.org/support/users/t_ed/)
 * (@t_ed)
 * [4 years, 5 months ago](https://wordpress.org/support/topic/sorting-bug-3/#post-15221943)
 * Yes, regardless that I do not see cached version when logged in as admin.
    -  This reply was modified 4 years, 5 months ago by [T_ed](https://wordpress.org/support/users/t_ed/).
 *  Plugin Author [Gemini Labs](https://wordpress.org/support/users/geminilabs/)
 * (@geminilabs)
 * [4 years, 5 months ago](https://wordpress.org/support/topic/sorting-bug-3/#post-15222245)
 * Try this:
 * 1. Add the following snippet to your functions.php file (or use the [Code Snippets](https://wordpress.org/plugins/code-snippets/)
   plugin): [https://pastebin.com/x0VFeHeY](https://pastebin.com/x0VFeHeY)
 * 2. Edit the `/finmaxfx-reviews/` page and use the Custom Fields Metabox to remove
   the `_glsr_average` and `_glsr_ranking` values **(after verifying that the _glsr_average
   value is 2.3!)**. If you are using the Gutenberg Block editor, you can enable
   the Custom Fields panel in the Gutenberg page preferences.
 * ![](https://i0.wp.com/i.imgur.com/vDdcIN4.png?ssl=1)
 * 3. Once you have removed those values, load the `/forex-brokers-ratings/` page
   and verify that the rating is now 0. If it is not, then you have a caching problem.
 * 4. If the rating is 0, go to the Site Reviews Tools page and run the “Reset Assigned
   Meta Values” tool again to recalculate the average and ranking values.
    -  This reply was modified 4 years, 5 months ago by [Gemini Labs](https://wordpress.org/support/users/geminilabs/).
 *  Thread Starter [T_ed](https://wordpress.org/support/users/t_ed/)
 * (@t_ed)
 * [4 years, 5 months ago](https://wordpress.org/support/topic/sorting-bug-3/#post-15222362)
 * Thank you for your efforts, trully fantastic support.
    Method you suggested did
   not worked, unfortunately after doing all steps you provided values still were
   incorrect. But it seems like I have found the culprit and it is **zero star rating
   values**. Seems like when someone leaves zero stars the plugin calculates overall
   values incorrectly – internally numbers and externally output are different (
   have no idea how is this possible). I modified zero star review to higher value
   and that did the trick. I will recheck my guess again with another post to make
   sure I am right with that and come back to let you know the result. It was not
   the cache, I purged it several times, tried another browser, incognito mode, 
   disabled caching plugin – all with no result.
    -  This reply was modified 4 years, 5 months ago by [T_ed](https://wordpress.org/support/users/t_ed/).
 *  Thread Starter [T_ed](https://wordpress.org/support/users/t_ed/)
 * (@t_ed)
 * [4 years, 5 months ago](https://wordpress.org/support/topic/sorting-bug-3/#post-15222405)
 * Yes, the zero stars reviews caused the problem. I changed them to 1 star, then
   used “Reset Assigned Meta Values” tool and everything is fine.

Viewing 5 replies - 1 through 5 (of 5 total)

The topic ‘Sorting bug’ is closed to new replies.

 * ![](https://ps.w.org/site-reviews/assets/icon-256x256.gif?rev=3307009)
 * [Site Reviews](https://wordpress.org/plugins/site-reviews/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/site-reviews/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/site-reviews/)
 * [Active Topics](https://wordpress.org/support/plugin/site-reviews/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/site-reviews/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/site-reviews/reviews/)

 * 5 replies
 * 2 participants
 * Last reply from: [T_ed](https://wordpress.org/support/users/t_ed/)
 * Last activity: [4 years, 5 months ago](https://wordpress.org/support/topic/sorting-bug-3/#post-15222405)
 * Status: resolved