Sort & MinHeap Based 
SortingMinHeap
# Sorting

```javascript []
var kthLargestValue = function (matrix, k) {
    const m = matrix.length, n = matrix[0].length;
    let values = [];
    let prefixXOR = Array.from({ length: m }, () => Array(n).fill(0));

    for (let i = 0; i < m; i++) {
        for (let j = 0; j < n; j++) {
            let xorValue = matrix[i][j];
            if (i > 0) xorValue ^= prefixXOR[i - 1][j];
            if (j > 0) xorValue ^= prefixXOR[i][j - 1];
            if (i > 0 && j > 0) xorValue ^= prefixXOR[i - 1][j - 1];

            prefixXOR[i][j] = xorValue;
            values.push(xorValue);
        }
    }

    values.sort((a, b) => b - a); // Sort in descending order
    return values[k - 1]; // k-th largest
};
```

# MinHeap

```javascript []
const kthLargestValue = (matrix, k) => {
    const m = matrix.length, n = matrix[0].length;
    let prefixXOR = Array.from({ length: m }, () => Array(n).fill(0));
    const minPQ = new MinPriorityQueue() //Leetcode built-in

    for (let i = 0; i < m; i++) {
        for (let j = 0; j < n; j++) {
            let xorValue = matrix[i][j];
            if (i > 0) xorValue ^= prefixXOR[i - 1][j];
            if (j > 0) xorValue ^= prefixXOR[i][j - 1];
            if (i > 0 && j > 0) xorValue ^= prefixXOR[i - 1][j - 1];

            prefixXOR[i][j] = xorValue;

            minPQ.enqueue(xorValue);
            if (minPQ.size() > k) {
                minPQ.dequeue(); // Remove smallest element to maintain size k
            }
        }
    }

    return minPQ.front().element; // k-th largest element
};
```
['Array', 'Bit Manipulation', 'Sorting', 'Heap (Priority Queue)', 'Matrix', 'JavaScript']