Moved db sorting from samplerecords to setup