Introduce sorted keyid array functions and use in DB4.