added support for sorting array