This site has been archived and you can no longer log in or post new messages. For up-to-date community resources please visit

eZ Community » Forums » Setup & design » How to sort arrays of ez content...

How to sort arrays of ez content objects?

How to sort arrays of ez content objects?

Tuesday 16 September 2008 5:02:54 pm - 7 replies

I want to sort array of ez content objects by the object name. The problem is that I'm not getting them with a fetch which would sort them properly because I need to create custom array that contain some ez content object.

Does anyone know a good solution?

Wednesday 17 September 2008 1:16:17 pm

I have the same question.

Wednesday 17 September 2008 1:29:18 pm

You can create a new hash array and sort it afterwards using an extension:


{def $new_array = array()} 
{foreach $children as $child}
		{set $new_array=$new_array|append(hash('name',$,'ezobject',$child))}

{set $new_array=$new_array|sort}

Modified on Wednesday 17 September 2008 4:46:17 pm by Andreas Adelsberger

Wednesday 17 September 2008 4:44:15 pm

Thanks Andreas for your solution it's great and work fine for my project, only one thing I have declared variable as an array:

{def $new_array = array()}

Wednesday 17 September 2008 4:46:46 pm

You are welcome. I fixed it in the code above.

Thursday 24 November 2011 10:46:10 am

Thank you Andreas and Daniele.

This is a good solution to my problem too!

Thursday 03 May 2012 2:04:33 pm

Thx Andreas, your solution is good.

Thursday 16 August 2012 11:29:07 am


I have the same problem I need to sort an array of ez objects.

Could you give a detail example of the use of this extension, i just tried this but it doesn't work :

 {def $new_array = array(2,8,4,33,4,7)} 
{set $new_array=$new_array|sort()}

Nothing is printed.





You must be logged in to post messages in this topic!

36 542 Users on board!

Forums menu

Proudly Developed with from