Title: krsort error
Last modified: August 26, 2022

---

# krsort error

 *  Resolved [gm1980](https://wordpress.org/support/users/gaurav1980/)
 * (@gaurav1980)
 * [3 years, 9 months ago](https://wordpress.org/support/topic/krsort-error/)
 * Hi Guys,
 * We have added this in function.php of our theme and we are getting this error.
 * krsort requires parameter.
 * Please see attached.
 * //* Permalink Manager Required
    function pm_custom_uris_order() { global $permalink_manager_uris;
 *  krsort($permalink_manager_uris);
    }
 * Can you please let us know what needs to be updated for this.
 * Thanks

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

 *  Thread Starter [gm1980](https://wordpress.org/support/users/gaurav1980/)
 * (@gaurav1980)
 * [3 years, 9 months ago](https://wordpress.org/support/topic/krsort-error/#post-15951916)
 * Please see attached images here:-
 * [https://i.ibb.co/ZKycWy2/Screen-Shot-2022-08-23-at-9-37-25-PM.png](https://i.ibb.co/ZKycWy2/Screen-Shot-2022-08-23-at-9-37-25-PM.png)
 * [https://i.ibb.co/r7h590B/Screen-Shot-2022-08-23-at-9-32-52-PM.png](https://i.ibb.co/r7h590B/Screen-Shot-2022-08-23-at-9-32-52-PM.png)
 * [https://i.ibb.co/F0DgGDk/Screen-Shot-2022-08-23-at-9-33-31-PM.png](https://i.ibb.co/F0DgGDk/Screen-Shot-2022-08-23-at-9-33-31-PM.png)
 *  Plugin Author [Maciej Bis](https://wordpress.org/support/users/mbis/)
 * (@mbis)
 * [3 years, 9 months ago](https://wordpress.org/support/topic/krsort-error/#post-15952766)
 * Hi [@gaurav1980](https://wordpress.org/support/users/gaurav1980/),
    I am not 
   sure how this function is called (which hook and priority), but it appears to
   be executed before the **$permalink_manager_uris** global is populated with data.
   Because the variable’s value is null, ksort() returns an error.
 * You should keep two things in mind:
    1. Make sure the variable is indeed an array before trying to sort it
    2. Make sure that your code is called after the $permalink_manager_uris variable
       is filled with data
 * The “plugins_loaded” hook with priority 10 is the first time you can run the 
   sorting function.
 *     ```
       //* Permalink Manager Required
       function pm_custom_uris_order() {
       	global $permalink_manager_uris;
   
       	if(is_array($permalink_manager_uris)) {
       		krsort($permalink_manager_uris);
       	}
       }
       add_action('plugins_loaded', 'pm_custom_uris_order', 10);
       ```
   
 * Best regards,
    Maciej
 *  Thread Starter [gm1980](https://wordpress.org/support/users/gaurav1980/)
 * (@gaurav1980)
 * [3 years, 9 months ago](https://wordpress.org/support/topic/krsort-error/#post-15953311)
 * Thanks Maciej

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

The topic ‘krsort error’ is closed to new replies.

 * ![](https://ps.w.org/permalink-manager/assets/icon.svg?rev=2625166)
 * [Permalink Manager Lite](https://wordpress.org/plugins/permalink-manager/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/permalink-manager/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/permalink-manager/)
 * [Active Topics](https://wordpress.org/support/plugin/permalink-manager/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/permalink-manager/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/permalink-manager/reviews/)

 * 3 replies
 * 2 participants
 * Last reply from: [gm1980](https://wordpress.org/support/users/gaurav1980/)
 * Last activity: [3 years, 9 months ago](https://wordpress.org/support/topic/krsort-error/#post-15953311)
 * Status: resolved