Questions tagged [sorting]
Sorting is the process of applying some order to a collection of items.
sorting
77,149
questions
0
votes
0
answers
10
views
Sort results of DataView are different in different versions of .Net Framework
The GoodsNo column of the DataView has two pieces of data, HB3-T017 and HB-T015, which are now sorted by GoodsNo, with different results in .Net2.0 and 8.0.
The order under .Net2.0 is HB3-T017, HB-...
-4
votes
1
answer
36
views
Why is swapping using function and swapping using assignment produce in different results?
This is the code for Quick sort in which i used assignment to swap the values.
def partion(arr,low,high):
partion_index=low
pivot=arr[partion_index]
while (low < high):
while low < ...
0
votes
2
answers
54
views
Why did std::sort use this simple strict weak ordering compare still crash? [duplicate]
Here is my code:
#include<vector>
#include<algorithm>
#include<iostream>
using namespace std;
void test()
{
vector<vector<int>> info = {{0,0,999}, {0,1,1000}, {0,2,...
-1
votes
0
answers
20
views
What should I focus while learning DSA? [closed]
So basically I am learning DSA for the first time and I dont want to overlearn or learn things that aren't neccessary. Can anyone tell me what I should focus on?
DSA learning I am learning quick union ...
1
vote
1
answer
18
views
MultiLabelBinarizer: inverse_transform How can get a list of labels sorted according to their probability?
I am doing a multi label classification and I use MultiLabelBinarizer to translate the list of labels into Zeros and Ones.
I could get the Labels using inverse_transform which is super. However, in a ...
0
votes
0
answers
30
views
How do I make await function last less than one millisecond?
I am currently making a sorting algorithm visualizer using HTML, CSS, and JS. I have most of it down, but I want to give it the ability to sort faster than one comparison a millisecond.
Here is my ...
0
votes
1
answer
59
views
How to store row-position in a database?
I am looking to emulate a feature in Excel/Google Sheets where there is a table of data, but someone may move a row up or down. Here is an example of the interaction:
My first thought as to how to ...
-8
votes
0
answers
68
views
Why does caching/memoization in a sorting comparator increase runtime instead of reducing it? [closed]
I'm solving a problem on Leetcode where I need to sort an array of integers based on their mapped values using a custom digit mapping. I’ve implemented two versions of the solution to address this ...
0
votes
0
answers
63
views
Sorting a DataFrame by Multiple Conditions in Pandas
I'm struggling with a specific sort that I'm not managing to implement in Python.
Here's a sample dataframe
import pandas as pd
data = {
'product': ['A', 'A', 'A', 'B', 'B', 'B'],
'quantity': ...
-1
votes
1
answer
71
views
Shuffle the Array - LeetCode problem. 2 pointers approach fails [closed]
I am trying to solve LeetCode problem 1470. Shuffle the Array:
Given the array nums consisting of 2n elements in the form [x1,x2,...,xn,y1,y2,...,yn].
Return the array in the form [x1,y1,x2,y2,...,xn,...
0
votes
1
answer
52
views
Understanding Time complexity of nested sorting
I am solving this LeetCode problem 1636. Sort Array by Increasing Frequency:
Given an array of integers nums, sort the array in increasing order based on the frequency of the values. If multiple ...
-3
votes
1
answer
116
views
Confused about the sort() function in C++ [duplicate]
I've just done a problem on Leetcode. But I was confused about the sort() function of C++.
This is more detail about it:
Given an array of integers nums, sort the array in increasing order based on ...
2
votes
1
answer
32
views
How to compare sorting with lookup in mongodb 4.4?
I'm new to mongodb, I'm on version 4.4, no update possible.
I have a collection items with an attribute categories (array). I would like to "join" ($lookup) the collection categories to it - ...
1
vote
3
answers
127
views
Behaviour of std::is_sorted function in C++
Consider the following C++ program which checks whether the given array is sorted or not.
#include <iostream>
#include <vector>
#include <algorithm>
int main()
{
std::vector<...
4
votes
0
answers
97
views
Why is np.sort() with order slow on multi dtype arrays? (sorting by unsigned integer ID)
Working with embedded software, I'm using numpy arrays with specified datatypes to save memory and other reasons. I'm using version '1.23.4' and Python 3.10.0, but this seems to be an issue with ...