[libcontacts] Use internal IDs for contact sequence management

The strings used in Qt5Contact contact IDs are very slow to compare.
Cache the sorted index of contacts

Otherwise all our ID-based lookups require a traversal.
Reduce conversions between contact ID types