The Bible does not see the world this way. In fact, it speaks against it in very explicit terms.
Here’s a law in the Book of Exodus: “Do not pervert justice by siding with the crowd, and do not show favoritism to a poor person in a lawsuit.”
Here’s one in Leviticus: “Do not pervert justice; do not show partiality to the poor or favoritism to the great but judge your neighbor justly.”
Moses, the greatest lawgiver in history, declares in Deuteronomy: “Follow justice and justice alone.”
And the New Testament declares in the Book of Romans: “God shows no partiality.”
None of this means that there is no place for compassion in a system of justice. Of course, there is. The Bible is preoccupied with the protection of the widow, the orphan, and unfortunate. But compassion follows justice. It doesn’t precede it.