implemented key-selector support for toArray()