Jump to content

Sorting an object array


yanisdon

Recommended Posts

Hi there,

I've got an array of objects. The

print_r()

looks like this:

stdClass Object
(
    [type] => book
    [name] => Book page
    [module] => book
    [description] => A book is a collaborative writing effort: users can collaborate writing the pages of the book.
    [help] => 
    [has_title] => 1
    [title_label] => Title
    [has_body] => 1
    [body_label] => Body
    [min_word_count] => 0
    [custom] => 0
    [modified] => 1
    [locked] => 1
    [orig_type] => book
)
stdClass Object
(
    [type] => event
    [name] => Event
    [module] => basicevent
    [description] => An event is a planned event with a start and end date, and displays in the events calendar.
    [help] => 
    [has_title] => 1
    [title_label] => Title
    [has_body] => 1
    [body_label] => Body
    [min_word_count] => 0
    [custom] => 0
    [modified] => 1
    [locked] => 1
    [orig_type] => event
)
stdClass Object
(
    [type] => blog
    [name] => Blog entry
    [module] => blog
    [description] => A blog is a regularly updated journal or diary made up of individual posts.
    [help] => 
    [has_title] => 1
    [title_label] => Title
    [has_body] => 1
    [body_label] => Body
    [min_word_count] => 0
    [custom] => 0
    [modified] => 1
    [locked] => 1
    [orig_type] => blog
)

 

What I like to be doing here is basically to sort 'alphabetically' by [type]. I can't use

 sort()

since it expects an array.

Any ideas?

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.