service: helper function for sorting services

Created a helper function to sort service list, to shorten the code
slightly and to ensure null pointer check is always done before using
the list pointer.

[connman] service: helper function for sorting services