Ruby solution: 2 loops, sort and map.
Leetcode: 1030. Matrix Cells in Distance Order.\n\nAlgorithm of this solution: \n- Iterate all cells of a matrix in two loops,  first loop is external second is
##### Leetcode: 1030. Matrix Cells in Distance Order.\n\nAlgorithm of this solution: \n- Iterate all cells of a matrix in two loops,  first loop is external second is nested.\n- During iteration fill array with parks, cell coordinates and distance from input cell.\n- Sort array by second element of a pair.\n- Map array to leave only cell coordinate as an element of the array.\n- Return this array as result.\n\nRuby code:\n```Ruby\n# Leetcode: 1030. Matrix Cells in Distance Order.\n# https://leetcode.com/problems/matrix-cells-in-distance-order/\n# Runtime: 208 ms, faster than 50.00% of Ruby online submissions for Matrix Cells in Distance Order.\n# Memory Usage: 14.3 MB, less than 50.00% of Ruby online submissions for Matrix Cells in Distance Order.\n# @param {Integer} r\n# @param {Integer} c\n# @param {Integer} r0\n# @param {Integer} c0\n# @return {Integer[][]}\ndef all_cells_dist_order(r, c, r0, c0)\n    array = []\n    (0...r).each do |row|\n        (0...c).each do |cell|\n            array.push([[row,cell], (row-r0).abs + (cell-c0).abs])\n        end\n    end\n    array.sort_by(&:last).map(&:first)\nend\n```
['Ruby']