tagged [multidimensional-array]

How to use LINQ on a multidimensional array to 'unwind' the array?

How to use LINQ on a multidimensional array to 'unwind' the array? Consider the following array: `int[,] numbers = new int[3, 2] { { 2, 1 }, { 3, 4 }, { 6, 5 } };` I would like to use LINQ to construc...

How to create multidimensional array

How to create multidimensional array Can anyone give me a sample/example of JavaScript with a multidimensional array of inputs? Hope you could help because I'm still new to the JavaScript. Like when y...

14 Aug at 06:30

Java Comparator class to sort arrays

Java Comparator class to sort arrays Say, we have the following 2-dimensional array: How should Java `Comparator` class be declared to sort the arrays by their first elements in decreasing order using...

Obtaining the min and max of a two-dimensional array using LINQ

Obtaining the min and max of a two-dimensional array using LINQ How would you obtain the min and max of a two-dimensional array using LINQ? And to be clear, I mean the min/max of the all items in the ...

15 Jun at 21:39

How can I create a two dimensional array in JavaScript?

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. 1....

Printing 2D array in matrix format

Printing 2D array in matrix format I have a 2D array as follows: I want to print the values of this array in matrix format like: How can I do this?

28 Mar at 09:58

Calculate mean across dimension in a 2D array

Calculate mean across dimension in a 2D array I have an array `a` like this: I need to calculate the mean for each dimension separately, the result should be this: `45` being the mean of `a[*][0]` and...

How do I find the size of a 2D array?

How do I find the size of a 2D array? If I declare this array... Then I can measure the length with which is 12. How do I measure the dimension of the arrays within? If I try... ``` a[0].Length

15 Dec at 07:59

Sort an array of associative arrays by column value

Sort an array of associative arrays by column value Given this array: I would like to sort `$inventory`'s elements by price to get: ``` $inventory = array( array("type"=>"pork", "price"=>5.43), arra...

How to get a complete row or column from 2D array in C#

How to get a complete row or column from 2D array in C# I do not want to use a jagged array and I have a 2D array and I want to get a complete column or row without looping through it. Does anyone hav...

6 Aug at 15:16

c# assign 1 dimensional array to 2 dimensional array syntax

c# assign 1 dimensional array to 2 dimensional array syntax I want to do something like: is this somehow possible and what is the syntax? or I need to do this: ``` for (int i = 0; i

8 Jul at 16:52

How do I make a flat list out of a list of lists?

How do I make a flat list out of a list of lists? I have a list of lists like `[[1, 2, 3], [4, 5, 6], [7], [8, 9]]`. How can I flatten it to get `[1, 2, 3, 4, 5, 6, 7, 8, 9]`? --- [python list compreh...

How to sum all column values in multi-dimensional array?

How to sum all column values in multi-dimensional array? How can I add all the columnar values by associative key? Note that key sets are dynamic. Input array: ``` Array ( [0] => Array ( ...

11 Nov at 10:22

Difference between array.GetLength(0) and array.GetUpperBound(0)

Difference between array.GetLength(0) and array.GetUpperBound(0) What is the difference between these two methods and when would you use one instead of the other? MSDN says that GetLength return the n...

26 Aug at 09:17

How to compare multidimensional arrays in C#?

How to compare multidimensional arrays in C#? How to compare multidimensional arrays? Just true/false. Is there way to compare 2d arrays like 1d array ? ``` data1.SequenceEqua

Initialize 2D array

Initialize 2D array I am trying to initialize a 2D array, in which the type of each element is . So far, I can only initialize this array in the follow way. ``` public class ticTacToe { private char[...

12 Dec at 04:38

2D arrays in Python

2D arrays in Python What's the best way to create 2D arrays in Python? What I want is want is to store values like this: so that I access data like `X[2],Y[2],Z[2]` or `X[n],Y[n],Z[n]` where `n` is va...

How to convert a 1d array to 2d array?

How to convert a 1d array to 2d array? Say, I have a 1d array with 30 elements: How to convert the 1d array to 2d array? Say 10x3? Should I use a for loop? But I cannot work it out.

15 Feb at 15:58

Javascript Map Array Last Item

Javascript Map Array Last Item I have this: It maps through a 2-dimentional array. After each row, I'd like to insert ``. I think, if I could somehow get the last index for each row, so I will be able...

Loop over array dimension in plpgsql

Loop over array dimension in plpgsql In plpgsql, I want to get the array contents one by one from a two dimension array. But the above code returns: in one line. I want to be able to loop ov

in_array() and multidimensional array

in_array() and multidimensional array I use `in_array()` to check whether a value exists in an array like below, but what about an multidimensional array (below) - how can I check that value whether i...

9 Sep at 12:26

Rotating a two-dimensional array in Python

Rotating a two-dimensional array in Python In a program I'm writing the need to rotate a two-dimensional array came up. Searching for the optimal solution I found this impressive one-liner that does t...

7 Dec at 19:31

How do you get the width and height of a multi-dimensional array?

How do you get the width and height of a multi-dimensional array? I have an array defined: This is all well and good, but I need to know how wide this array is in the `x` and `y` dimensions individual...

17 Aug at 16:59

Unexpected value of System.Type.FullName

Unexpected value of System.Type.FullName I recently needed to build C# specific name (which must always include global:: specifier) for an arbitrary type and have come accross following issue: ``` // ...

How to initialize a two-dimensional array in Python?

How to initialize a two-dimensional array in Python? I'm beginning python and I'm trying to use a two-dimensional list, that I initially fill up with the same variable in every place. I came up with t...

7 Mar at 17:44