Sorting for Friends

- Friends are now ordered properly
- Also, some refactoring of javascript functions
- Still need: push data to the server, loading screens for requests