digital root sort algorithm

I'm running through challenges on codefight and all tests pass except 1 "hidden test" where I'm unable to see the test data inserted... I'm looking for help pointing out what I'm missing or a failing test case with my solution. Problem: Digit ro...
more »

2017-06-18 23:06 (1) Answers

Keeping Multidimensional Array's Semantic?

Today's the first day I've really gotten stuck into creating anything from scratch in PHP7. My script skills are pretty rudimentary anyway, so I apologise in advance. I've been looking at tutorial pages + searching Google/Stack and can't seem to fin...
more »

2017-06-18 19:06 (1) Answers

Make square bracket not appear on a new line?

I am currently working with a .txt file containing data points of certain files. Since the files are pretty big, are they been processed in smaller parts, but the output extracted from the processing process is not sorted in any order.. They are s...
more »

2017-06-18 13:06 (1) Answers

How to keep array index>value after sorting

in javascript I have next array: var a = [0, 2, 1, 3]; Where this array index>value pair is: 0 = 0, 1 = 2, 2 = 1, 3 = 3 What is simplest and most elegant way of keeping array index numbers after sorting an array. After sort() index>value p...
more »

2017-06-18 12:06 (2) Answers

Swift - display a sorted array with keys

I am want to display the three highest grades along with the names My code: let gradesofStudent = [ "Elias Brown": 80, "Baris Yan": 99, "Christian Najm": 70, "Sam Chakra": 90, "Alain Elliot": 55, "Georges Obama": 77, ] v...
more »

2017-06-17 22:06 (2) Answers

How to sort collection by array?

How to sort given collection Collection { #items: array:3 [ 0 => MenuPosition, // ->label = "About Us" 1 => MenuPosition, // ->label = "Homepage" 2 => MenuPosition // ->label = "Shop" ...
more »

2017-06-17 22:06 (2) Answers

De duplication of hashes and arrays

I have an array of hashes lets say offers = {offer1,...,offer6}. Each offer is a hash. Each offer has various keys one of which is a price hash: offer1 = {..., :price => {:amount => 400, :amount2 => 300, :currency => "INR",...} Now I want to retur...
more »

2017-06-17 15:06 (0) Answers

Sort list of strings by order of numeric parts

I have a list of paths of files, which I want to sort in ascending order based on the first path of each list. The list of paths is show $`HG-U133_Plus_2` [1] "C:\\Users\\agaz\\AppData\\Local\\Temp\\Rtmp0wZI21/008947515435900b4d1a0b8d/22" [2] "C:\\U...
more »

2017-06-17 13:06 (2) Answers

Extracting and sorting data from a binary file

So I just started a programming course in python and I have this assignment called 'Wind data analysis' in which I am to extract data from a bin.file and sort it into x,y and z values. So far I got: filename="turb21351_L72u.bin" with open(filename,...
more »

2017-06-17 11:06 (1) Answers

Sort CSV file alphabetically in Ruby

self.students.includes(:events).each do |student| row = [] row.push student.first_name row.push student.last_name row.push student.title row.push student.id csv << row end As of now, each user's data is inputted into t...
more »

2017-06-16 23:06 (1) Answers

How can I merge this array? Php

I've been trying to merge this array for several hours, however I do not get it, I have two arrays, one called 'period' and another 'time' period "periodo":{"periodo":[["2017-06-22","2017-06-23","2017-06-24"],["2017-06-22","2017-06-23","2017-06-24"...
more »

2017-06-16 20:06 (0) Answers

Sorting a range, Excel says range is empty

I try to sort a range (containing 3 columns) I want to sort the data on the second column and if there are two things the same in that column I want it to sort it via the first column. The second and the first column are always filled in. Here is ...
more »

2017-06-16 10:06 (1) Answers

Scala: sort list by sum of duration

I have the following classes: Task(id: String, time: Duration) Product(id: String, tasks: List[Task]) Then, I have a list list: List[Product] with the following elements: ("P1", List(Task("T1", 15 minute), Task("T2", 10 minute))) ("P2", List(Ta...
more »

2017-06-15 23:06 (3) Answers

How to sort numbers in a large text file

My task is to sort a large text file (>1GB) where numbers are arranged one per row as in the following example: 1906885614 1069046615 1576929003 1690826360 1540261768 786870227 1737467783 295136587 685162468 This is what I have done so far. #inc...
more »

2017-06-15 16:06 (2) Answers