Java sort array by the third element

i want to sort a String array descendant by it's third column in descend, the problem is that i want to sort by it's numeric value. Example: If i have this array initially: String [][] array = new String[][] { {"Barcelona", "156", "1604"}, {"...
more »

2017-01-11 22:01 (2) Answers

How can I pass an Array into a Laravel Controller

I have a number of arrays within my Laravel view that I would like to pass into the controller. These arrays should not be modified by the user, and are only there because they are passed from another method in the controller, (the view is acting as ...
more »

2017-01-11 18:01 (1) Answers

Slice an array with an inline PDO query

I'm trying to slice an array but getting an error "array_slice() expects parameter 1 to be array" Will appreciate any help! foreach(array_slice(($pdo->query($query)), 0, 3) as $row_Results) { $pic_id = $row_Results['pic_id']; ...
more »

2017-01-11 17:01 (1) Answers

Can't find an object in ArrayList

I'm trying to find an object in an array list that's in another class by using the name of the object. private void listParticipant() { System.out.print("Put in name of participant to see if currently registered: "); String name = readString...
more »

2017-01-11 13:01 (1) Answers

JavaScript function composition from 3 functions

I'm using Vue and trying to filter an array of results using a JS function composition. My Vue computed values are like so, but can't get filteredByAll to accept a third option getByThing. Right now the filterByAll just filters on the category and k...
more »

2017-01-11 12:01 (1) Answers

Check if Structure is empty C

My program is supposed to differenciate given measurements into cycles and then it to a file. The input file looks like this: reading | force | displacement | velocity 1 | 64.69 | 49.67 | 0.002 2 | 64.54 | 49.66 | 0.002 3 ...
more »

2017-01-11 12:01 (0) Answers

xml data into cakephp 3.x data array

i am trying to perform pagination on a xml data string in CakePHP 3.x , for this it is required for me to convert the 'xml data string' into a data array and then pass the data array object into the pagination method. But i can't convert the xml data...
more »

2017-01-11 07:01 (0) Answers

swift - using .map on struct array

i have a struct array that i want "break up" into smaller arrays that can be called as needed or at least figure out how i can map the items needed off one text value. the struct: struct CollectionStruct { var name : String var description...
more »

2017-01-10 22:01 (3) Answers

Undefined index in array element

seem to be experiencing something strange. I am loading an Excel file's data into an array. I am handling things like so foreach ($data->toArray() as $value) { dd($value); if(!empty($value)){ foreach ($value as $v) { ...
more »

2017-01-10 17:01 (1) Answers

output different elements from two arrays

I am trying to output different elements from two arrays. So if i have an array A: {9, 0, 1} and B is {0, 8, 1}, I need to output an element which included in the first set, but are not included in the second :9 Can not think how I should compare all...
more »

2017-01-10 16:01 (4) Answers

Can't Call arrays in main method

I'm practicing methods, but the problem is I want to separate inputting and sorting, the display method will be the main, I'm having trouble fixing this calling from other class. This is my script : using System; using System.Collections.Generic; u...
more »

2017-01-10 12:01 (4) Answers

How to Convert an String array to an Int array?

I have made research for a couple hours trying to figure out how to convert a String array to a Int array but no luck. I am making a program where you can encrypt a message by using three rotors. I am able to type a message and get the index number...
more »

2017-01-10 10:01 (6) Answers

Store array globally in struct or other method

I have an array of struct elements that I would like to store globally so that I can access it in different classes without having to run the query that populates it over and over. I have a struct: struct collectionStruct { var name : String ...
more »

2017-01-10 10:01 (3) Answers

total array sum using pdo

I'm trying to get total price from cart table. The product_price in other table which is product. I'm only getting the latest price not the total price. Thanks // function total_price (){ $total = 0; global $db; $ip = getIp(); $sql = $d...
more »

2017-01-10 04:01 (1) Answers

Creating a data structure in JavaScript

I am currently attempting a JavaScript challenge on FreeCodeCamp. I have been working on this challenge for a few days now and am stumped. I asked for help on the site's forum but the response I got wasn't very helpful or useful. For this particula...
more »

2017-01-09 21:01 (2) Answers

Multidimensional data type in Scala

I have a generic class, which is constructed from multi-dimensional data (i.e. n-dimensional Ararys or Vectors). In this case, I would like the class to be instantiated by one type only (e.g. Vector), aside from its dimensionality (Vector[Vector[T]] ...
more »

2017-01-09 17:01 (1) Answers

Flip an image stored as a byte array

I have an image which is stored as a byte[] array, and I want to flip the image vertically before writing the bytes to disk elsewhere. The image bytes come from a compressed jp2 image file. I've looked into implementing something like Flip image sto...
more »

2017-01-09 17:01 (2) Answers

How to find elements loactions is numpy array

I have a 2D array, from which I want to get the indices of every element that is in the top 2 values both in it's row and in it's column. For example, given the following array - r = np.random.rand(5,5) >>> r array([[ 0.89771084, 0.844154...
more »

2017-01-09 09:01 (1) Answers