fix sorting by metadata filed