Add array sort by function