sorting

R: Sort multiple columns by another data.frame?

I'm trying to make sense of how to sort one data.frame based on multiple columns in another. This question does this with vectors. Can someone suggest a way to do the equivalent with data.frames? Here's some sample data. x1 <- data.frame(a=1:5, b=letters[1:5], c=rnorm(5)) x2 <- data.frame(a=c(4,4,2), b=c("d", "d", "b"), d=rnorm(3)) ...

Random Sorting Results in Lucene.Net 2.4

How do I sort my results in a random order. my code looks something like this at the moment: Dim searcher As IndexSearcher = New IndexSearcher(dir, True) Dim collector As TopScoreDocCollector = TopScoreDocCollector.create(100, True) searcher.Search(query, collector) Dim hits() As ScoreDoc = collector.TopDocs.scoreDocs For Each sDoc As ...

ordering categories with php arrays

I have an array of categories: categories = computers, entertainment, products, graphics cards The array is sometimes returned in the wrong order BUT each category has a parent which exists in the SAME array. categories = products[parent=0], entertainment[parent=products], computers[parent=entertainment], graphics cards[parent=com...

std::map sort by data?

Is there a way to sort std::map by the data rather than the key? Right now my code duplicates the entire map in to an array just to do this. ...

Creative sorting algorithm?

I just wanted to know if there are any sorting algorithms that are as interesting as Bogosort to sort a pack of cards. Use your creativity. For a change efficiency ain't important but being creative is :) ...

sorting a gridview bound to a linq SP

hi there I have a grid bound to a linqed SP thus: Session["results"] = db.spGetCaseByNumberOrSurname(txtCaseNum.Text.Trim(), null).ToList(); gvResults.DataSource = Session["results"]; on the sorting of it, i would like to be able to do this.. protected void gvResults_Sorting(object sender, GridViewSortEventArgs e) { ...

Can I pass arguments to the compare subroutine of sort in Perl?

I'm using sort with a customized comparison subroutine I've written: sub special_compare { # calc something using $a and $b # return value } my @sorted = sort special_compare @list; I know it's best use $a and $b which are automatically set, but sometimes I'd like my special_compare to get more arguments, i.e.: sub special_compare...

Unix sort is not consistent!

Hi i'm running the commands zcat [File] | sed "1d" | sort -t $'\xE7' -k [field to be sorted] > [file].sorted When i run this on File A sorting on field 1 i get 11622400 , abe, def 11622401 , abe, def 11622402 , bbabe, def 11622403 , ddabe, def 11622404 , acdc, dere 11622405 , ddabe, bere 11622406 , abe, fgh 11622407 , adbed, ddee 11...

How to sort a multi-dimensional XML file??

I have tried to get an XML file to sort and have had no luck. After a day and a-half, I need some help from an expert. Thanks. My XML File (shortened for the example): <?xml version="1.0" encoding="iso-8859-1"?> <deadlines> <deadline> <date>2010-06-01</date> <text>Application for Summer Due</text> </deadline> ...

Need to allow users to sort file order

Hi All, I have a website where an admin can login and upload photos. All the images are placed in a directory and then on another page, i am cycling through the images and displaying them. The client has asked if there is a way to move the images around and place them in any order they want. Now looking at the site, i'm not sure what o...

scala sort a list by object parameter error

Ok, I wouldn't be coming to You for help if I knew what to do, anyways, still having problems with my "program". class Mark(val name: String, val style_mark: Double, val other_mark: Double) {} object Test extends Application { val m1 = new Mark("Smith", 18, 16); val m2 = new Mark("Cole", 14, 7); val m3 = new Mark("James", 13, 1...

Aliases for Multi-Column Sort

What are some other names for a multi-column sort? ...

CakePHP sort ignore case

I've got to sort a list of Reservations (they're coupled to an event by defining a belongsTo association) by the last name of the person who registered the ticket. I do this in cakePHP: $reservations = Set::sort($eventinfo['Reservation'],'{n}.last_name','asc'); This works, but some users input their data in all lowercase, which makes...

How can I efficiently determine if two lists contain elements ordered in the same way?

I have two ordered lists of the same element type, each list having at most one element of each value (say ints and unique numbers), but otherwise with no restrictions (one may be a subset of the other, they may be completely disjunct, or share some elements but not others). How do I efficiently determine if A is ordering any two items ...

Python: Sorting this list

`li = [(1106257, (255, 255, 255)), (1, (16, 16, 118)), (1, (32, 32, 128)), (1, (48, 48, 122)), (9, (249, 249, 249)), (1, (64, 64, 126)), (406, (247, 247, 251))]` I want to sort li depending on the first number in each element eg.1106257, 1, 1,1,9,1,406 How to do this fast? Thanks ...

How to sort the list by its accountID using quick sort in Haskell.

Im a student who is really new to functional programming. Im working on a banking application where the data has been already defined as, type Accountno = Int data Accounttype = Saving | Current | FixedDeposit deriving (Show,Read) type Accountamount = Int type Name = String type Account = (Accountno, Name, Accounttype, Accountamount)...

Order Integers In Ascending and Descending Orders

I'm working with Objective-C, but probably it doesn't matter the programming language for this. So basically I have an array, with say, the integers 12, 5, and 17, and I want to be able to pull out the largest number, or the smallest, or second smallest, etc. Basically I want to be able to sort them into ascending or decending order so...

How to sort C++ array in ASC and DESC mode?

Hi, I have this array: array[0] = 18; array[1] = -10; array[2] = 2; array[3] = 4; array[4] = 6; array[5] = -12; array[6] = -8; array[7] = -6; array[8] = 4; array[9] = 13; how do I sort the array in asc/desc mode in C++? ...

Groovy: sort hash keys by values value

I want to sort a hash of key->value by the values , and get the list of the sorted keys. This seems to work: groovy> def map = [a:5, b:3, c:6, d:4].sort { a, b -> a.value <=> b.value }.keySet() groovy> println map [b, d, a, c] but will it always work? I don't know if the iterator that builds the keySet() will always iterate the...

Different collections for different data sorting

Hello. I have a task to play with Java Collections framework. I need to obtain a users list from a database, and store it in a collection. (This is finished and users are stored in a HashSet). Each user is an instance of Person class described with name, surname, birth date, join date, and some other parameters which are not important no...