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

learn more… | top users | synonyms (1)

1
vote
2answers
37 views

Sorting a list and another list inside each item

I have a list of factories. Each factory has an item of its own and a list of other items from competitors. I need to sort the list of factories based on price of their items and also sort list of ...
1
vote
1answer
257 views
-1
votes
0answers
20 views

Bubble sort algorithm in swift [on hold]

import Foundation var array: [Int] = [99, 88, 56, 3, 1, 91, 43, 11, 53] func swapNum(indexOne :Int, indexTwo :Int) { let tempNum = array[indexOne] ...
3
votes
2answers
50 views

Duplicates in array elements and sorting

I've been given this little test exercise for an interview as php developer, and I'd like to hear from you if my solution is good (enough) or if the problem could have been solved in a better way. ...
3
votes
2answers
55 views

Merge and sorting arrays of String and int in more efficient methods

Are there better methods for merge and sorting arrays of int and String in more efficient methods both time-complexity wise and ...
0
votes
0answers
40 views

Parallel integer tree sort algorithm in Java

Introduction In this post, I will present a parallel sorting algorithm for sorting primitive integer arrays. Treesort Treesort is an algorithm which iterates over the input array and constructs a ...
0
votes
0answers
29 views

Ruby Sort Hash for same value [closed]

I have hash like hash = {"n"=>5, "a"=>4, "h"=>3, "m"=>3, "y"=>3, "f"=>2, "r"=>2, "i"=>2, "e"=>2, "d"=>2, "s"=>2, "z"=>5} now i ...
0
votes
1answer
61 views

Radix sort in Java

As homework I had to implement many sorting algorithms including radix sort in Java. The task is to sort doubles in the range [0-1) that are rounded to the 10th ...
3
votes
1answer
45 views

Sort stack using two stacks

My program is supposed to sort a stack such that the smallest item are on the top. I can use a temporary stack, but you may not copy the elements into any other data structure. The program works ...
4
votes
1answer
74 views

Checking to see if array can be sorted using only one operation

I'm doing this HackerRank problem, which asks whether an array of up to 100000 integers can be sorted in ascending order by exactly one of the following: swapping two elements reversing a subarray ...
2
votes
3answers
63 views

Sort array of hashes with nil values last

I wrote method which sorts an array of hashes by given hash keys. The method should put nil values at the end. ...
5
votes
1answer
60 views

Sort a strings collection by a search term

I'm trying to implement a search bar in which the user sends a search term and the search bar displays the results. I have a naive solution which separates the original list into three sublists: a ...
1
vote
1answer
44 views

Haskell Non-Dominated sorting

This algorithm sorts a list of Individuals, each with two fitness values, into what's called non-dominated fronts. A non-dominated front is a set of individuals where none of the individuals dominate ...
2
votes
1answer
51 views

Optimizations for bubble sort

The code performs bubble sort on the basis if any swaps has been performed in the iteration. I made it sort of independent of number of iterations as in any conventional bubble sorting code. I went ...
5
votes
3answers
353 views

Bubble sort algorithm in Java

I have written this code which basically sorts the array using bubble sort, however, I feel it is not very readable. Please let me know me how I can improve this code. ...
1
vote
2answers
49 views

Compare function for lists

I need to sort a list of lists. The following is a compare function: ...
4
votes
1answer
60 views

Sort a stack in descending order

Maintain current element as the top element in the input stack. Pop all the elements on the ordered stack which are greater than the current element and push them in to the input stack and maintain a ...
1
vote
0answers
35 views

JavaScript drag-and-drop sortable list

I made a simple list with drag and drop ordering function using JavaScript, HTML and CSS. Although I tried to do this as efficient as possible, I'm sure there are some improvements to be made. What ...
4
votes
2answers
44 views

Sorting a file with three-line blocks by the second word of the first line in each block

I have a text file with the following three line pattern with blank lines in between. My script sorts alphabetically by each person's last name and preserves formatting. I would love to see other ...
4
votes
1answer
57 views

Bubble Sort in C

I am trying to learn C coming from Python. Below is an implementation of bubble sort, slightly optimized. Any advice on best practices, readability, use of macros, and edge cases would be greatly ...
2
votes
2answers
41 views

Re-sorting newsfeed based on date

Background: A client side I made recently has a component that is made from several (20+) rss-feeds, and the feeds are mashed into one using FreshRSS hosted on our servers. For some reason, FreshRSS ...
1
vote
1answer
10 views

Organizing a Python list of lists as function of number of occurances

I am having a Python list of lists, that I get as an output of python-igraph (membership to clusters). The integers represent an association of a vertex to a ...
5
votes
2answers
119 views

Counting sort using STL

I'm trying to learn to use the C++ Standard Library and some of the modern C++11 features. Can someone review my counting sort algorithm below and critique my style/algorithm/use of the STL? Thank ...
4
votes
1answer
80 views

Sort algorithm in c

I wrote this algorithm a while ago, and decided to revisit it and polish it up. It basically works by comparing each number with all the other numbers once, so comparing the first number to all ...
2
votes
1answer
64 views

Clustering similar tweets in a corpus

I am attempting to write a statistical program using an LDA model I've trained/created using Gensim. I am very new to Python and am a student level programmer. This current program is working and ...
2
votes
2answers
58 views

Designing a sorting algorithm from scratch

I'm taking a Python course and the current assignment is to create an algorithm that sorts numbers in ascending order (without using built-in sorting functions). I've had no programming experience ...
2
votes
1answer
48 views

Optimizing quicksort partition method/function for duplicate elements

I'm a newbie and interested in learning different data structures and algorithms. While implementing quicksort, I found this code works pretty well for partitioning. ...
5
votes
0answers
70 views

Topological sort using recursive DFS

I am currently learning Graph algorithms by solving questions on online judges. The below code is for implementing Topological sort, using recursive DFS. Also, it is my first time with C++ STL. ...
1
vote
1answer
50 views

My implementation of counting sort [closed]

I've made the following implementation of counting sort. I don't think that I understand the algorithm fully but this implementation seems to be working correctly. I've used the ...
2
votes
0answers
22 views

Recursive bubble sort in OCaml

I'm new in OCaml and just want to be sure that I write code in "ocaml way". My other first programs in OCaml was imperative and looks like python-code. So I decided to write simple code and share it ...
6
votes
3answers
353 views

Sorting a String based on its words

Is there a better, more efficient or nicer way to do this? ...
2
votes
1answer
28 views

Python - insertion sort

Series post - I am reading through Introduction to Algorithms, 3rd Edition implementing each algorithm as I read them. Pretty basic insertion sort. Only considering numbers initially - how could I ...
7
votes
2answers
103 views

Bucket sort in Haskell

As a first step in learning Haskell I am solving this problem, which involves finding the Rith-ranked numbers, given some input list and many Ri. In an imperative language I would make a zeroed array ...
8
votes
2answers
90 views

Melsort — Sorting with encroaching lists

For the nth time already I come back with yet another alien sorting algorithm. Today I will present Melsort, implemented from the description I found in the paper Encroaching Lists as a Measure of ...
5
votes
1answer
107 views

C# Sorting array without using the bubble sort

I'm a beginner and like to experiment new things so today I tried to implement sorting method for an array without using any Sort and the actual challenge was to do ...
1
vote
1answer
104 views

UVA #10258 - Contest Scoreboard

The problem statement is here. Problem Description The task is to rank the contestants in the contest based on following criteria Contestants are ranked first by the number of problems solved (the ...
4
votes
1answer
85 views

Quicksort implementation in Java

I wrote this implementation of quicksort as a bit of practice and review for myself. I did not base my algorithm on anything more than my own understanding of quicksort and working through a couple ...
3
votes
3answers
79 views

Hackerrank Insertion Sort Part 2

I have started learning Java recently and was looking into the challenges on sorting on Hackerrank.I solved the following problemHackerrank on Insertion Sort. The challenge was : In Insertion ...
3
votes
1answer
72 views

Basic sorting in Python

Previously asked here. I would like to get my code for implementation of simple sorting algorithms in idiomatic python code reviewed. I am looking for feedback on python idioms used, better ways of ...
2
votes
1answer
74 views

Implementing basic sorting in Python

I would like to get my code for implementation of simple sorting algorithms in idiomatic python code reviewed. I am looking for feedback on python idioms used, better ways of doing the same thing. I ...
0
votes
2answers
79 views

Sorting List on basis of certain letter

I am trying to sort a list on basis of C before . Is there better way to do this? ...
5
votes
1answer
68 views

Sorting an array of time-specific tasks of varying importance

RULES: Strict tasks must occur at the time the user selected no matter what. Flex tasks are in a priority order. Even if there is a gap big enough to fit several flex tasks with lower priority, no ...
2
votes
0answers
62 views

Parallel merge sort in Java

I have rolled my own parallel merge sort. My performance figures are as follows: Seed: 1457521330571 java.util.Arrays.sort() in 6840 ms. Sorted: true java.util.Arrays.parallelSort() 3777 ms. ...
3
votes
2answers
43 views

SortedList implementation in Java

I've implemented a SortedList which takes in streams of floats and returns a median at any point. ...
2
votes
0answers
40 views

Sort Algorithms in Julia

Similar to this question here, I am trying to implement sort algorithms in Julia, as part of a package. The code for the implementation is as follows: ...
2
votes
0answers
23 views

Guidance on grouping equal sets of numbers, so each group has a similar average

Goal: I am trying to build teams of 5 people. Each person has an integer elo (rank). My goal is to make all the teams as equal/fair as possible, by having the average elo of each team be as close as ...
3
votes
3answers
63 views

generate word list based on Spanish text file

I'm a beginner and wrote a program takes a text file and writes a downcased vocabulary list to another text file. I intend to use it mainly to work with text in Spanish, so I added a line to downcase ...
3
votes
1answer
73 views

Faster QuickSort

I'm trying to make my QuickSort faster than it is and I have got no more ideas about how to make it more efficient for all types of arrays but mostly very big arrays. It uses random to create the ...
1
vote
1answer
48 views

Mapping and sorting lists of Haskell tuples

I'm a newbie with Haskell and I'm trying to learn the language and its idioms while working through a small data analysis project. The first step of my analysis is to take a very long list of data, ...
3
votes
2answers
83 views

Quicksort for a pseudosite

I have a pseudosite, where I actually post small functions, so that I can re-use them*, but some posts have visitors. The top is Quicksort (C++). I feel that beginners visit it, so I do not care in ...