Use uasort() to maintain your keys
uasort()
This function sorts an array such that array indices maintain their correlation with the array elements they are associated with, using a user-defined comparison function.