Questions tagged [sorting]

Sorting is the process of applying some order to a collection of items.

Filter by
Sorted by
Tagged with
1
vote
1answer
66 views

C++ vector bubble sort in my edition

I made a small adaptive function that sorts vector: ...
1
vote
0answers
47 views

In place dynamic array sorting without using extra memory

I seek critique on a sorting implementation for a dynamic array data-structure. Design decisions Uses the quicksort algorithm. Uses an optimized XOR swap for swapping the elements. XOR swap doesn't ...
3
votes
0answers
34 views

I recently wrote sort of structs in golang

I am a bit concerned about style (functions, variable names, spacings, etc.). I am also not sure about whether I should return error or panic. What do you think? ...
1
vote
1answer
39 views

I have a query like this that seems complicated and I want to do it by using Java Stream Api

I have method that fetches sorted and filtered data from Mysql Database, Firstly I had done It by using Java. Now I did it by Mysql but I don't like the way the code looks I have entity that named ...
2
votes
2answers
56 views

Trying for an efficient and readable heap-sort implementation

I'm looking for any sort of optimization and/or conventional practice tips, such as using the appropriate data types and naming my variables appropriately. ...
3
votes
3answers
64 views

Trying for an efficient and readable merge-sort implementation

My first implementation of merge sort in C++. I'm looking for any sort of optimization and/or conventional practice tips, such as using the appropriate data types and naming my variables appropriately....
2
votes
3answers
52 views

PHP Sort Associative Array first by relativity of value then by other value desc

I am trying to sort an associative array by following this scheme: Sort by 'qt': positives first, non-positives after. Magnitude does not matter, only sign. In positive part: sort by sa DESC In ...
3
votes
2answers
146 views

Sorting an array of positive integers including 0 much faster than Radix Sort

I was working on an Limit Order Book structure in JS and came up with this algorithm. I am pretty sure this must have already been implemented but couldn't even find a clue over the web. The thing is, ...
1
vote
0answers
63 views

How to make this algorithm faster. Calculates and searches through large arrays

Ive got this algoritm thats "complex". The comments in code give examples of how large the various data types could be. My cpu usage is less than 10% when running this and ram usage is good. ...
2
votes
1answer
64 views

Generating a performance report for clans in Clash Royale

The following code generates a report showing performance of clan members in a game called Clash Royale. Everything is pretty self-explanatory, we are working with a lot of https requests, arrays and ...
0
votes
2answers
71 views

Is my Insertion Sort optimal?

I'm learning sorting algorithms and wrote my own implementation of Insertion Sort. Is it optimal? Is there anything that can be done better? ...
2
votes
1answer
81 views

C++ Incredibly Precise Sorter | Efficiency and speed of sorting algorithms

Hey Guys, I'm in the process of building a console program in C ++ that allows users to: sort a sequence of numbers loaded from a TXT file save sorted sequence in a new TXT file measure the sorting ...
11
votes
6answers
3k views

Mergesort Criticism in C

I have written a merge sort in C and would like any advice on how to improve it. Any advice helps to make the code better! ...
2
votes
2answers
165 views

Recursive function for bubble sort

I often see nested loops as a solution to the bubble sort, but my solution involves a recursive function. Is the following solution less efficient than the traditional method? ...
1
vote
1answer
53 views

Insertion Sort- inserting from the left

I've implemented my own insertion sort algorithm, and here's the code. ...
3
votes
0answers
42 views

Breadth First Search Block Puzzle

I am creating a program that will be given a text file as output with the board's dimension and the piece id along with the piece width and length. The goal is to arrange all blocks in the board ...
2
votes
2answers
70 views

Sorting alphabetically ascending and descending using .sort()

I have created this basic use case of .sort() for my own reference. I am asking for a review to see if there are bad practices present or areas that could be ...
3
votes
0answers
65 views

Quicksort using Lomuto partition scheme in C

This is my implementation of the divide-and-conquer Quicksort algorithm using the Lomuto partition scheme in C. This is part of a personal project and I'm following Linus Torvalds's coding style. <...
0
votes
1answer
98 views

Array member set its own index in the array

I'm writing a code where a class member, if != -1, set its own position at array. If the value is == -1, the next free index (whose range is 0 too array's length) is used. In this review, I'm more ...
4
votes
2answers
53 views

Radix Sort Speed

I have implemented a radix sort algorithm in Python 3. It first finds the maximum number of digits in the list, then changes them to strings and adds 0's. For example, [7, 23, 107, 1, 53] to ['007', '...
5
votes
1answer
111 views

Quicksort Algorithm Speed

I have made a sorting algorithm in Python 3. This sorting algorithm is a modified optimized median of 3 quicksort, with network sorting for lists of size up to 16 and for finding the median. I have ...
0
votes
1answer
53 views

C.Insertion sort with guard

I have already addressed this issue and corrected something .really..now the graph looks different Please tell me if the program works correctly?You can see the results in the picture above.I will be ...
0
votes
3answers
135 views

sorting vector of pair in efficient way

I'm trying to solve the sorting problem but I always get TLE(Time Limit Exceeded/ 1s) so... can you guys suggest a more efficient way to solve this problem? (i can't link the exercise because it is on ...
13
votes
3answers
2k views

Count word frequencies, and print them most-frequent first

I'm writing a comparison of a simple word-counting program in various languages. The task is to count the frequencies of unique, space-separated words in the input, and output the results most ...
1
vote
0answers
47 views
2
votes
0answers
28 views

Sort items so that parents are created before their children

I've been asked to create some code to help automate the loading of data into a system based on employee data in a spreadsheet. However, the data isn't clean, so some people may have no manager, some ...
2
votes
3answers
70 views

Read and sort an array of integers

...
3
votes
1answer
60 views

Programming Pearls — Column 1: Sorting unique numbers with bitfield

I've implemented a simple program to sort an input of unique numbers given as decimals on a separate line. The idea is, since all numbers are unique, to use a (long) bitfield where a 1 on index n ...
0
votes
1answer
25 views

Calculating ordered differences between elements in vector

Input I start with a vector of integers or floats, e.g.: [10, 100, 20, 5, 50] Output I want to return a list of differences or "deltas" between elements ...
3
votes
1answer
84 views

benchmarking sorting algorithms: std::sort vs my naive radix

I'm comparing performance of two sorting algorithms applied to sort integers using google benchmark. I'm quite surprised by the results so wanted to ask if you see some mistakes in the way I measure ...
1
vote
1answer
139 views

MSD Quick Radix Sort in Place in C++, Object/Pointer Oriented

Memory: O(log2(max)*2)~O(1) Speed: O(log2(max)*n)~O(n) so i did before a MSD Radix Sort in place but i wanted to do one, with out the count, So i join together the quick sort and radix sort. Think as ...
1
vote
1answer
56 views

Binary Radix Sort implementation on linked list

I am trying to implement binary radix sort in C which sorts a linked list of integers stably. Although my algorithm has a time complexity of O(log2(k).n) (where k ...
0
votes
1answer
115 views

MSD Radix sort in Place in c++, Object/Pointer Oriented

Memory:O(log(max)base(mod)*mod)Speed:O(log(max)base(mod)*n) I did a radix sort in place to not get a auxliar array. In the process i discorver a few things. Is imposible to do LSD radix sort in place ...
1
vote
1answer
124 views

Read and sort 100 numbers from a text file

The program itself reads 100 values from a text file named input.txt. Then sorts those values in ascending order and writes the values to a new file called ...
0
votes
1answer
85 views

Big Sorting - Performant Sorting

Consider an array of numeric strings where each string is a positive whole number. Sort the array's string elements in ascending order of their numeric values, and return the sorted array. Return: ...
0
votes
0answers
13 views

Simple Parallel Sorting

i had made a simple parallel sorting for my personal games. it did well so far, but i would like to get some advises about how to improve it further or perhaps there are an alternative methods for ...
3
votes
2answers
76 views

Sorting a list but the sort order isn't known until runtime

I need to sort a list of strings that I'm reading in but the sorted order of that list is not predetermined (I can't hard code it); I read in the sort order from a source and build a comparator by ...
2
votes
2answers
88 views

Sorting program code

I have done a sorting program, it works but I am new to the coding world and I would love to hear your thoughts. ...
4
votes
3answers
489 views

Sorting Nested Array

Recently on SO there was this question i am trying to get sequence index of each array of array like I have an element of the array and that 5 arrays have multiple elements and I want to get the ...
0
votes
0answers
47 views

Sorting Algorithm Visualiser in React with TypeScript

This code animates sorting algorithms in the browser. I've included all the React components I've used and left out the individual sorting algorithm implementations. SortingVisualiser.tsx ...
2
votes
1answer
58 views

Covid-19 World Case Report Beta 0.1

I am a self-learned programmer and this is my first program. I would really appreciate any critique on my approach. The program should automatically download the who data file to the folder these ...
1
vote
0answers
180 views

PowerShell - Sort strings containing numbers numerically

I am a newbie in programming, but I do have potential, I am using PowerShell to hone my skills, I have written a simple function to sort strings consisted of numbers humanly (i.e. in a order like 1 2 ...
4
votes
1answer
131 views

Performant Sort function for big arrays

In sort(arr), I want to sort an array. Children must be beneath their parent. And children of the same parent are sorted using ...
4
votes
0answers
111 views

Sorting Algorithm (from scratch) in Python

Updated (at the bottom) I am attempting to write a Python program where I have to create a sorting algorithm without the assistance of the built-ins (like the sort()...
1
vote
1answer
66 views

Pandas DataFrame.sort_values() new method to exclude by row name

I was working on new function with Pandas DataFrame. It's meant to sort values by column name but exclude specific rows from sorting and return sorted dataframe with that has rows with preserved ...
-1
votes
2answers
75 views

Remove duplicates from array and save it to another one [duplicate]

I have been tasked to make an array without duplicated values from another existing array. So I did it, but I want to know is there some other better way to do that. Example input/output ...
3
votes
3answers
136 views

Remove duplicates from array and save it to another one

So I have been tasked to make an array without duplicated values from another existing array. So I did it, but I want to know is there some other better way to do that. Example input/output: ...
3
votes
1answer
77 views

How do I optimize the bubble sort in Assembly8086?

I tried to implement bubble sort in Assembly 8086. ...
5
votes
2answers
110 views

Best way to find the largest sorted suffix in a list - USACO Sleepy Cow Sorting Python

Solving this problem. Right now, my solution entails finding the largest sorted sublist, starting from the beginning, all the way to the end. However, I feel like the way I wrote the ...
4
votes
1answer
498 views

Hybrid Merge/Insertion sort algorithm

Explanation: Although merge sort runs in Ω(nlgn) and insertion sort runs in Ω(n^2), the constant factors in insertion sort can make it faster in implementation for small problem sizes. This sorting ...

1
2 3 4 5
22