Friends are initially sorted by level and game activity. Friends who haven't logged in to the game for 90 days are moved to the bottom of the list and receive a "sleeping" icon.
You can also sort your friends by talent by pressing the corresponding icon in the Friends tab.
If you add a friend to your Favorites, they will always remain at the top of the list and be marked with a star.