Sorting Array of Objects using Ruby and Python

From my previous post, I had explained on how to sort an array consists of objects by object’s attribute using PHP. While on PHP sorting by object’s attribute requires additional function other than sorting itself, Ruby and Python has it’s own array of object sorting syntax. For example in Ruby, the following one line syntax will sort an array named population by comparing it’s objects length property (attribute) ascendingly without Continue reading Sorting Array of Objects using Ruby and Python

Sorting Array of Objects Using PHP

Consider you have an array or list of objects and wanted to sort it based on one attribute of objects. If the array consists of integer, it is very easy to sort it ascendingly using sort() function, otherwise if the array consists of objects, you have to create custom sorting function which is passed to the PHP usort() function. Here is an example on how to manually sort array of Continue reading Sorting Array of Objects Using PHP