Skip to main content

All Questions

Tagged with
0 votes
2 answers
67 views

How do optimise Array.sort or what is the best way to sort large size JSON

i am using default array.sort method inside my application here is my sample code const jsonArray = Array.from({ length: 100000 }, (_, i) => ({ id: i, principle: Math.random() * 1000, ...
New User's user avatar
-2 votes
1 answer
110 views

How to sort a 2d array in Apps script (google sheet) base on a 1d array

I have a script that I have been using for some time, but I recently had a bug on the data sorter and since then I have been unable to fix the problem. I transpose arrays because they are normally ...
Romain Gapteau's user avatar
-1 votes
4 answers
178 views

C++ sorting an array [closed]

I'm building a payroll program. It outputs one line at a time that contains employee ID, name, gross pay... and so on. I each line in order based on netpay. The only sorting methods I know, or that my ...
Matthew Klick's user avatar
0 votes
0 answers
50 views

How can I count how many times multiple items show up in a database? [duplicate]

I would like to count each multiple of the items in an array returned from a SQL query: $results = $stmt->fetchALL(PDO::FETCH_ASSOC);. So if there are 5 instances of John and 3 of Sue in the db, ...
I.Tornquist's user avatar
-2 votes
3 answers
135 views

How is this sorting the array in Java during merge [closed]

I was just reviewing some merge sorting and finding that I'm missing how when merging it is storing the sorted arrays. import java.util.Arrays; public class MergeTwoArrays2 { public static void ...
April_Nara's user avatar
  • 1,050
2 votes
3 answers
228 views

How to sort a list of object by two fields when the first field is a date but of string type and the second field is a plain string

I have an array of Object that I need sorted by two of the object's fields. Product.java private String productionDate; private String productionCountry; private String productDescription; Now I ...
craftdeer's user avatar
  • 1,067
2 votes
1 answer
76 views

is there any problem in the terms of time complexity in this code?

So today I was learning selection sort, and gain the concept how actually selection sort it working(i mean we add new element in the sorted array then check that element if it is on its correct ...
Ashish shah's user avatar
-5 votes
3 answers
99 views

How to sort my array by length of its keys array in javascript? [closed]

How to sort my array by length of its keys array in javascript ? my_array = []; my_array['a'] = ['val1', 'val2']; my_array['b'] = ['val1', 'val2', 'val3']; my_array['c'] = ['val1', 'val2']; my_array['...
al-dr's user avatar
  • 147
3 votes
1 answer
92 views

Why should native sorting functions be called by array_walk() with explicit sorting function parameters?

I ran a few tests on 2d arrays and found that in some contexts, native sorting functions can give unexpected results when array keys are 2, 5, 10, or 13. $expected = range(0, 11); $array = array_fill(...
mickmackusa's user avatar
  • 48.4k
7 votes
6 answers
430 views

How to move duplicates to the end of an array while preserving order in C?

I need to write a function in C that processes an array by moving all duplicate elements to the end of the array. The function should preserve the relative order of distinct elements, but the order of ...
Nature9376's user avatar
-1 votes
1 answer
28 views

sorting internal index of multidimensional array with column in PHP

I have a JSON record I converted to a PHP array. $db=array( array("Name"=>"Beans","Price"=>"10"), array("Name"=>"Salad","...
mike_s's user avatar
  • 27
2 votes
2 answers
94 views

LINQ - How to correctly group a list of users by their nested list of values

I have List<User> with this dependencies: class User { public string Id { get; set; } public List<ManagerGroup> ManagerGroups { get; set; } } class ManagerGroup { public string ...
Nick ANV's user avatar
-1 votes
1 answer
47 views

How to retain the index of an array element after flattening and sorting into descending order using sort() [duplicate]

I have a 2D array of integers. I need to find the largest value within the entire array along with its index. Currently I am flattening the array and then using the sort() function to find the highest ...
CottonDog's user avatar
-1 votes
5 answers
213 views

How to sort 2D array from horizontal (left-to-right) to vertical (top-to-bottom)

I want to convert the 2d array which is missing some values and has been sorted from left to right to a new array which is sorted from top to bottom like below examples. Cols and rows and the number ...
Gold Chicken's user avatar
0 votes
2 answers
60 views

Javascript Array Object, return result in correct order

I have a created a array object. To simplify it I have just kept two fields, id and name. I want to filter the mainArray and return the result in the order of the [3,9,1] as seen in the filterArray ...
Powl_London's user avatar

15 30 50 per page
1
2 3 4 5
1154