Questions tagged [sorting]
Sorting is the process of applying some order to a collection of items.
75,185
questions
0
votes
0
answers
7
views
End_date Condition
Good Day
Trying to understand if it is possible to have a script with a condition of " todays date"
#original Values
start_date = '2021-01-01'
end_date = '2023-01-20'
I've tried these , ...
0
votes
0
answers
17
views
Sorting within CosmosDB based on different parameters
I have a problem where it comes to custom sorting.
I need to sort elements based on 3 factors:
ID (string)
Flag (boolen)
Date (datetime
Sample data records:
[
{
id:"f95b3289-2da3-45d2-bc39-...
-1
votes
1
answer
45
views
Check times within an Array and Print the latest in a Time Range
Let's say I have a list of data in the following format:
ID#,YYYYMMDD HH:MM:SS.sss,score
So the data could look like this:
501,20220104 13:12:07.005,25
501,20220104 13:12:07.002,25
500,20220106 09:04:...
1
vote
1
answer
23
views
Count up if value changes in other dataframe columns
My input is:
d = {'x': [1479903, 1479879, 1479926, 1479736, 1479760, 1479784, 1479808, 1479831, 1480331, 1480355, 1480949, 1480973, 1480997, 1481021, 1481877, 1481901, 1481924, 1481948, 1481996, ...
-1
votes
1
answer
35
views
How do I sort values in a list of arrays based on two separate elements in the array?
I have a list as follows:
my_list = [['Sample',
'B1',
17,
(0.10996957123279572,
0.012014645151793957,
0.07346764951944351,
0.7748424410820007)],
['Errand',
'F8',
55,
(0....
-1
votes
1
answer
20
views
Create Product Sort System using JavaScript [duplicate]
How would I be able to create a product sort system using JavaScript
I have this Array:
let products = [
{
productName: "Product1",
price: 40
},
{
...
0
votes
0
answers
10
views
ReactJS Ant Design Table handle before sort event
I want to handle event before sorting on Table component of Ant Design with ReactJS. I knew that there is onChange event which provides information AFTER on every change were made, but I need a hook ...
-1
votes
1
answer
35
views
Processing a Python dictionary
Assuming I have a dictionary similar to this with variables IDs and PosX:
Dict={"ID":[], "PosX":[] }
I want to iterate trough all of it and create a new dictionary storing the ...
0
votes
1
answer
24
views
How to push a specific object at top of the array of objects, without disturbing the sequence using React.Js?
I am facing a little problem in code and seek your help .
Problem description :
( I have an array of objects (mainly 4 objects only), and each object is having the unique Id as its identifier primary ...
0
votes
2
answers
34
views
how to sort a dict by format dates values
I got a dict of names as keys and formated dates as values, I managed to have the list of these dates sorted, but I dont know how to now sort my dict with this "custom order", since the ...
0
votes
0
answers
11
views
Collecting different arrays, then pushing and sorting them in one array alphabetically
im trying to map and sort separate items alphabetically like this:
import {
Accordion,
AccordionSummary,
Button,
ListItemText,
MenuItem,
Select,
TextField
} from '@material-...
-2
votes
2
answers
31
views
How to filter and checked matches conditionally with multiple fields
How to filter and checked matches conditionally with multiple fields passing in string;
i have a request as like below:
{
name: "abc",
email: "",
phone: "123456",
match: ...
0
votes
1
answer
21
views
how to get first word repetitive at front then rest word in listagg?
I am not sure how to get the right script
usually, I use listagg by order by but I want something different
select
customer_id ,
listagg (car_product , '-' ) within group (order by car_product) as ...
0
votes
2
answers
44
views
How do I sort lists by two different values within that list?
I have a list that is of the following form:
my_list= [['A',(3,4)],['A2',(6,11)],['U1',(2,9)],['P9',(1,9)], ['X',(10,4)]...]
I need to sort the letter/number combinations based on the list that ...
-1
votes
1
answer
37
views
How to make data zig zag from a,a,a,b,b,b to a,b,a,b,a,b using php or sort? [closed]
How to make data zig zag from a,a,a,b,b,b to a,b,a,b,a,b using php or sort?
because i'm try usort but it can't be done
0
votes
2
answers
57
views
How do you divide up a list into chunks which vary according to a normal distribution
I want to take a list of thousands of items and group them into 12 chunks, where the number of items found in each chunk correspond to a normal distribution (bell curve) and no duplicates across ...
0
votes
1
answer
22
views
Extract coordinates from SVG String
let path_string='<path transform="matrix(1,0,0,-1,0,600)" stroke-width=".074" stroke-linecap="round" stroke-linejoin="round" fill="none" stroke=&...
0
votes
2
answers
22
views
How to make the 1st element of list of lists to match the order of elements in another list?
How can I make the 1st element of list of lists to match the order of elements in another list? For example:
list1 = [3, 7, 1, 10, 4]
list2 = [[1,0],[3,2],[4,11],[7,9],[10,1]]
newlist = [[3,2],[7,9],[...
0
votes
0
answers
17
views
React useState does not update after new array was assigned
I am trying to build a sorting visualizer in React.
Unfortunately, my useState doesn't update its value after a random array gets generated.
But in an earlier project it worked just fine.
I tried ...
0
votes
1
answer
10
views
How to add ascending - descending sort buttons in a bar chart using d3.js?
I'm trying to figure out how to add interactive features in a bar chart.
Now I'm stuck about program fuctions for a click action using a button to sort ascending and descending.
This is my code:
const ...
1
vote
2
answers
76
views
Sort the products based on the frequency of changes in customer demand
Imagine following dataframe is given.
import pandas as pd
products = ['Apple', 'Apple', 'Carrot', 'Eggplant', 'Eggplant']
customer_demand_date = ['2023-01-01', '2023-01-07', '2023-01-01', '2023-01-01'...
0
votes
1
answer
44
views
Javascript Array. Add first array to the first position that has a zero
How would I do the following as mentioned in the title. I have looked online and I can push, slice etc to add the item but I want the first value to go to the first available position in the array ...
-1
votes
0
answers
34
views
Add Page Number & Sort pages in pdf using Migradoc/Pdfsharp [closed]
I am currently using PdfSharp and MigraDoc to Merge Pdfs and from a input and create a New pdfDocument which consist of all merged pdf pages.
I have imported PDFsharp-MigraDoc package using Nuget ...
0
votes
2
answers
86
views
How can I change how Python sort deals with punctuation?
I'm currently trying to rewrite an R script in Python. I've been tripped up because it looks like R and Python sort some punctuation differently. Specifically '&' and '_'. At some point in my ...
-2
votes
2
answers
25
views
Why array is not showing proper result in react? [closed]
Below is the screen of my VScode, I am declaring arr1 as an array of numbers and later reversing it.Input
The problem is that on output the 1st paragraph is showing the reversed arrays instead of ...
-1
votes
1
answer
51
views
Python sort method key parameter [duplicate]
In the myFunc function below, where is the (e) argument passed in from? (I hope I'm using the right terminology)
# A function that returns the length of the value:
def myFunc(e):
return len(e)
cars ...
-2
votes
0
answers
24
views
Sorting Algorithms for sort array [duplicate]
When I use this code for sorting array:
let x = [40, 10, 30, 20, 50];
let cmp = (a, b) => a - b;
x.sort(cmp); // ascending order
console.log(x); // [10, 20, 30, 40, 50]
Is this Bubble ...
0
votes
1
answer
27
views
Find the most popular attribute across all nodes with a same xpath in XSLT 1.0
Given the example below, I would like the output to be commonest param is: ratio, which is the most popular name for a parameter.
<?xml version="1.0" encoding="UTF-8"?>
<...
0
votes
0
answers
37
views
ggplot2 visualization - How to tidy an x-axis with a lot of timestamps?
I visualized my data with a ggplot2-code. It worked really well, my only issue is the x-axis. R named all the dates, which lead to a chaotic state of the x-axis.
enter image description here
ggplot(...
0
votes
2
answers
51
views
Custom Sort a ListBox in C# Visual Studio
I'll start by giving an example cause it will be easier.
Lets say I have a ListBox that's named "lbDestinations" and I have a class for that listbox called Destination.
Destination.cs
public ...
0
votes
2
answers
39
views
Find tuples in a list of tuples, with consecutive values and turn them into bigger tuples
I have a list of tuples, each having two elements. Example:
my_tuples = [('black', 'grey'), ('red', 'orange'), ('blue', 'purple'),
('orange', 'yellow'), ('grey', 'white'), ('yellow', '...
0
votes
2
answers
29
views
Sort a 2-D array in Java based on one parameter first and then based on the second. [JAVA]
Let's say I have a 2-D array arr[][]:
col1 col2
[1, 7]
[2, 6]
[3, 9]
[4, 1]
[5, 3]
[6, 7]
and we have to sort it based on col1 1st and then based on col2
What is the way to do this in Java? ...
1
vote
2
answers
34
views
How to write an advanced function to select path and sort files?
function Sort-Size {
[CmdletBinding()]
param (
[Parameter(Mandatory)]
[string] $Name
[Parameter(ValueFromPipeline = $true)]
$Path,
$...
0
votes
2
answers
50
views
Sort values from smallest to largest among all string values Execution started and Execution ended
<!--00:00:13:23 - Execution started - 01042141053 - B Side
00:02:59:10 - VAR 10.2 = 'W2300900009'
00:02:50:78 - VAR 8.2 = 'W2300900007'
00:02:42:51 - VAR 6.2 = 'W2300900005'
00:03:45:18 - ...
-2
votes
0
answers
23
views
Query on Sorting a Map in Java [closed]
I want to sort a map in Java using comparator and lambda expressions but without using Streams. Also, the map should not be converted to list for sorting.
I am using below snippet to sort the map. But ...
0
votes
2
answers
70
views
why these 2 sorting is opposite in order [duplicate]
I am implementing bubble sort in Python and used range for indexing the array:
"""
program to implement bubble sort
"""
a = [9,1,5,3,7,4,2,6,8]
for i in range(len(a)):
...
-3
votes
0
answers
25
views
Error in Java code for sorting an array of numbers [closed]
I am trying to write a Java program to sort an array of numbers in ascending order. However, I am encountering an error in my code and I am not sure how to resolve it.
I expected my code to sort the ...
0
votes
0
answers
39
views
ARRAY SORTING - I sorted an array (doubles) using the bubble method but there was a string array with corresponded to it - now i cant put it in place
Im new in java and I am building a system that asks for the name of the course and then the grade the student got - I ask for users input and then display it, so i am using 2 arrays a string array and ...
-4
votes
0
answers
25
views
JS: How to sort on multiple properties? [duplicate]
I have a Object of object
var users = {
"382845": {
"userid": 251558,
"friendid": 382845,
"id": 382845,
"friendStatus": "friend",
"unread": 1
},
...
0
votes
1
answer
27
views
create new df column based on grouping and conditions in PYTHON
my dataframe looks like the bottom and i want to create a new column called "remove" that would be true/false based on the following conditions.
i only want to keep one row for each "...
0
votes
1
answer
40
views
how to pin a note and sort it in an array
I was creating a notes app in react which has a pin functionality such that when I click on the pin icon on a particular note that particular note is displayed first. the user should only be able to ...
0
votes
0
answers
23
views
How to sort array of strings representing dates based on calendar week
I have an array of strings in this format: "2023-01-30". The dates range from past, to present, to future. I want to sort the dates into separate arrays based on the work weeks (monday ...
-1
votes
0
answers
15
views
Quick Sort Alg and Time Complexity
I'm trying to learn different sorting algorithms and understand also understand their time complexity. Right now, I am working on a quicksort alg and I found a good video on YouTube explaining it. ...
0
votes
1
answer
19
views
Getting a Different Sort Order Between "SPSS sort cases by" and Python "sort_values(by=[])
I am attempting to convert some code from SPSS into Python. In the code, the SPSS "sort cases by" command is resulting in a different sorted order than the Pandas "df.sort_values(by=[]) ...
0
votes
1
answer
40
views
Select only 10 first minutes of each hour of a datetime list
I have a datetime list that looks like this, which contains every timestamp with approximately 125ms between each timestamp, between the 6th and the 14th and the 21th of june in 2019:
[datetime....
0
votes
3
answers
66
views
Sort list of map items based on unknown list of fields
I have a big list of HashMap<String, Object> items that I need to sort dynamically based on a list of fields.
If the list of fields were static, I know I could easily use Comparator.compare(..) ...
2
votes
2
answers
51
views
Java sorting by spread between two BigDecimal
Please help with sorting in Java. I have a simple example (looks like this).
I need to sort list by the difference between two BigDecimals.
My Data class (I cut getters)
public class Quotation {
...
0
votes
2
answers
40
views
Sorting and Array alphabetically
I have an Array I am trying to sort alphabetically by the description, unfortunately it's not doing anything.
I believe my code is right as it worked before, maybe I'm missing something basic but I ...
-1
votes
1
answer
20
views
Sort the characters of a string in ascending order using masm32 programming language [duplicate]
I am trying to make a program that accepts user input and sorts the characters of a string input in ascending order.
0
votes
3
answers
56
views
In Ruby, how can I sort an array of hashes
I am new to Ruby, could someone help?
I have some product data Json that I need to sort by the expiry date, however everything thing I have tried with .sort_by so far is erroring.
The Json is in this ...