Create a table that counts TP, FP, TN, FN at different thresholds

I developed a workflow for a binary classification model, and I would like to create a table that provides confusion matrix calculations at different threshold values:

  1. Table 1 sorts the predicted probabilities in descending order and shows the ground truth next to the probability (this part is easy). something like this:

| Row | Truth | Probability |
| 1   | 1     | 0.995       |
| 2   | 1     | 0.991       |
| 3   | 1     | 0.875       |
| 4   | 0     | 0.811       |
| 5   | 1     | 0.73        |
| 6   | 1     | 0.71        |
| 7   | 0     | 0.649       |
| 8   | 1     | 0.602       |
| 9   | 0     | 0.577       |
| 10  | 0     | 0.522       |
  1. Based on Table 1, Table 2 then counts the number of TP, FP, TN, FN at different threshold values ranging from 1 to 0:

| Cutoff | TP | FP | TN | FN |
| 1.0    | 0  | 0  | 3  | 7  |
| 0.9    | 2  | 0  | 3  | 5  |
| 0.8    | 3  | 1  | 3  | 3  |
| 0.7    | 5  | 1  | 3  | 1  |
| 0.6    | 6  | 2  | 2  | 0  |
| 0.5    | 6  | 4  | 0  | 0  |
| 0.4    | 6  | 4  | 0  | 0  |
| 0.3    | 6  | 4  | 0  | 0  |
| 0.2    | 6  | 4  | 0  | 0  |
| 0.1    | 6  | 4  | 0  | 0  |
| 0      | 6  | 4  | 0  | 0  |

Any help would be greatly appreciated.