Adding a rank function.