All Questions

1736
votes
29answers
941281 views

Making a flat list out of list of lists in Python

I wonder whether there is a shortcut to make a simple list out of list of lists in Python. I can do that in a for loop, but maybe there is some cool "one-liner"? I tried it with reduce, but I get an ...
416
votes
5answers
109926 views

How do I use arrays in C++?

C++ inherited arrays from C where they are used virtually everywhere. C++ provides abstractions that are easier to use and less error-prone (std::vector<T> since C++98 and std::array<T, n>...
809
votes
5answers
554653 views

Sort Multi-dimensional Array by Value

How can I sort this array by the value of the "order" key? Even though the values are currently sequential, they will not always be. Array ( [0] => Array ( [hashtag] => ...
376
votes
21answers
615472 views

How do I declare a 2d array in C++ using new?

How do i declare a 2d array using new? Like, for a "normal" array I would: int* ary = new int[Size] but int** ary = new int[sizeY][sizeX] a) doesn't work/compile and b) doesn't accomplish what:...
170
votes
25answers
147577 views

How to Flatten a Multidimensional Array?

Is it possible, in PHP, to flatten a (bi/multi)dimensional array without using recursion or references? I'm only interested in the values so the keys can be ignored, I'm thinking in the lines of arra...
187
votes
11answers
156569 views

How do I Sort a Multidimensional Array in PHP

I have CSV data loaded into a multidimensional array. In this way each "row" is a record and each "column" contains the same type of data. I am using the function below to load my CSV file. function...
205
votes
11answers
400963 views

Passing a 2D array to a C++ function

I have a function which I want to take, as a parameter, a 2D array of variable size. So far I have this: void myFunction(double** myArray){ myArray[x][y] = 5; etc... } And I have decla...
851
votes
39answers
1401115 views

How can I create a two dimensional array in JavaScript?

I have been reading online and some places say it isn't possible, some say it is and then give an example and others refute the example, etc. How do I declare a 2 dimensional array in JavaScript? (...
353
votes
9answers
108102 views

What are the differences between a multidimensional array and an array of arrays in C#?

What are the differences between multidimensional arrays double[,] and array-of-arrays double[][] in C#? If there is a difference, what is the best use for each one?
23
votes
4answers
4319 views

How do I correctly set up, access, and free a multidimensional array in C?

I have seen dozens of questions about “what’s wrong with my code” regarding multidimensional arrays in C. For some reason people can’t seem to wrap their head around what is happening here, so...

Previous Next