added key sort for indexes and foreign keys