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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T20:09:07+00:00 2026-05-26T20:09:07+00:00

I am attempting sort this array by each stdClass Object’s [title] in an Ubercart

  • 0

I am attempting sort this array by each stdClass Object’s [title] in an Ubercart order.tpl.php file. I have tried doing just a normal sort but since they all are stdClass Objects it doesn’t do anything.

<pre>Array
(
[0] => stdClass Object
    (
        [order_product_id] => 1157
        [order_id] => 142
        [nid] => 38
        [title] => Eatonville Forest Camping Permit
        [manufacturer] => 
        [model] => eatonville-camp-permit
        [qty] => 1
        [cost] => 9.00000
        [price] => 10.00000
        [weight] => 0
        [data] => Array
            (
                [attributes] => Array
                    (
                    )

                [shippable] => 0
                [restrict_qty] => 1
                [module] => uc_product
            )

        [order_uid] => 13
    )

[1] => stdClass Object
    (
        [order_product_id] => 1158
        [order_id] => 142
        [nid] => 35
        [title] => Eatonville Forest Motorized Recreation Access Permit and Release of Liability
        [manufacturer] => 
        [model] => eatonville-motor-rec-access
        [qty] => 1
        [cost] => 175.00000
        [price] => 175.00000
        [weight] => 0
        [data] => Array
            (
                [attributes] => Array
                    (
                    )

                [shippable] => 1
                [restrict_qty] => 1
                [module] => uc_product
            )

        [order_uid] => 13
    )

[2] => stdClass Object
    (
        [order_product_id] => 1159
        [order_id] => 142
        [nid] => 31
        [title] => Snoqualmie Forest Non-motorized Recreation Access Permit for Families and Release of Liability
        [manufacturer] => 
        [model] => snoqualmie-family-non-motor-rec-access
        [qty] => 1
        [cost] => 150.00000
        [price] => 150.00000
        [weight] => 0
        [data] => Array
            (
                [attributes] => Array
                    (
                    )

                [shippable] => 1
                [restrict_qty] => 1
                [module] => uc_product
            )

        [order_uid] => 13
    )

[3] => stdClass Object
    (
        [order_product_id] => 1160
        [order_id] => 142
        [nid] => 40
        [title] => Snoqualmie Forest Camping Permit
        [manufacturer] => 
        [model] => snoqualmie-camp-permit
        [qty] => 1
        [cost] => 300.00000
        [price] => 300.00000
        [weight] => 0
        [data] => Array
            (
                [attributes] => Array
                    (
                    )

                [shippable] => 1
                [restrict_qty] => 1
                [module] => uc_product
            )

        [order_uid] => 13
    )

[4] => stdClass Object
    (
        [order_product_id] => 1161
        [order_id] => 142
        [nid] => 39
        [title] => White River Forest Camping Permit
        [manufacturer] => 
        [model] => whiteriver-camp-permit
        [qty] => 1
        [cost] => 300.00000
        [price] => 300.00000
        [weight] => 0
        [data] => Array
            (
                [attributes] => Array
                    (
                    )

                [shippable] => 1
                [restrict_qty] => 1
                [module] => uc_product
            )

        [order_uid] => 13
    )

[5] => stdClass Object
    (
        [order_product_id] => 1162
        [order_id] => 142
        [nid] => 30
        [title] => White River Forest Family Non-motorized Recreation Access Permit for Families and Release of Liability
        [manufacturer] => 
        [model] => whiteriver-family-non-motor-rec-access
        [qty] => 1
        [cost] => 150.00000
        [price] => 150.00000
        [weight] => 0
        [data] => Array
            (
                [attributes] => Array
                    (
                    )

                [shippable] => 1
                [restrict_qty] => 1
                [module] => uc_product
            )

        [order_uid] => 13
    )

[6] => stdClass Object
    (
        [order_product_id] => 1163
        [order_id] => 142
        [nid] => 33
        [title] => White River Forest Non-motorized Recreation Access Permit for Individuals and Release of Liability
        [manufacturer] => 
        [model] => whiteriver-non-motor-rec-access
        [qty] => 1
        [cost] => 75.00000
        [price] => 75.00000
        [weight] => 0
        [data] => Array
            (
                [attributes] => Array
                    (
                    )

                [shippable] => 1
                [restrict_qty] => 1
                [module] => uc_product
            )

        [order_uid] => 13
    )

[7] => stdClass Object
    (
        [order_product_id] => 1164
        [order_id] => 142
        [nid] => 34
        [title] => Snoqualmie Forest Non-motorized Recreation Access Permit for Individuals and Release of Liability
        [manufacturer] => 
        [model] => snoqualmie-non-motor-rec-access
        [qty] => 1
        [cost] => 75.00000
        [price] => 75.00000
        [weight] => 0
        [data] => Array
            (
                [attributes] => Array
                    (
                    )

                [shippable] => 1
                [restrict_qty] => 1
                [module] => uc_product
            )

        [order_uid] => 13
    )
)</pre>

This is the code controlling it in the order.tpl.php

<pre>php if (is_array($order->products)) {
                        $context = array(
                          'revision' => 'formatted',
                          'type' => 'order_product',
                          'subject' => array(
                           'order' => $order,
                          ),
                        );
}
</pre>
  • 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-26T20:09:07+00:00Added an answer on May 26, 2026 at 8:09 pm

    I think usort() should work:

    function sortByTitle($a, $b){
      return strcmp($a->title, $b->title);
    }
    
    usort($theArray, 'sortByTitle');
    

    You may want to throw in some checking to make sure the title member actually exists.

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

Sidebar

Related Questions

I am attempting to query time data from MySQL in PHP, using this sort
I have sort of a tricky problem I'm attempting to solve. First of all,
I have had many attempts now on attempting to make this work and i
I am trying to sort my array while using NSPredicate.. I have read other
I'm attempting to sort of highlight a tile object within a game I'm making
I am attempting to use a UISegmentedControl to control the sort order of my
Does attempting to develop some sort of game, even just as a hobby during
I'm attempting to do a simple bubble sort code to get familiar with list/string
Attempting to use the data series from this example no longer passes the JSONLint
This is my first attempt at adding ajax to a WordPress plugin. I have

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.