Rust Sort & BinaryHeap
~~~\nuse std::collections::BinaryHeap;\n\nimpl Solution {\n    pub fn k_sum(nums: Vec, k: i32) -> i64 {\n        let mut sum = 0i64;\n        let n = nums.len()
~~~\nuse std::collections::BinaryHeap;\n\nimpl Solution {\n    pub fn k_sum(nums: Vec<i32>, k: i32) -> i64 {\n        let mut sum = 0i64;\n        let n = nums.len();\n        let mut data = vec![];\n        \n        for a in nums { \n            if a > 0 { sum += a as i64; }\n            data.push(i64::abs(a as i64));\n        }\n        data.sort();\n        \n        let mut pq = BinaryHeap::<(i64, usize)>::new();\n        let mut ret = sum;\n        \n        pq.push((-data[0], 0));\n        for _ in 2..=k {\n            let (val, i) = pq.pop().unwrap(); \n            ret = sum + val;\n            if i == n - 1 { continue; }\n            pq.push((val - data[i + 1], i + 1));\n            pq.push((val + data[i] - data[i + 1], i + 1));\n        }\n        \n        ret\n    }\n}\n~~~
['Sorting', 'Rust']