removed sorting from spec and adding to src
modified test cases with array spec checking