sorting

Some sorting problems (Core Data beginner)

Hi all. Maybe there is a simple solution to this, but I'm getting headache of this, I'm fairly new with all this Core Data stuff: I have a BankAccount class/entity with an "index" attribute, used for sorting, and a "transactions" to-many relationship to the Transaction class/entity. This Transaction entity has a "date" attribute, that ...

in unix, is it better to sort multiple small files, or one big file?

So I have multiple files that I am working on and they need to be combined and sorted. Would it be more efficient to sort each file first and use the sort -m option when combining the files, or to combine them first and then sort. Or is it the same? My understanding is that unix uses merge sort so in essence, would the one big file be ...

Can i sort the NSDictionary on basis of key in Objective-C?

Hello, Can i sort the NSDictionary on basic of key ? Thank You. ...

Jquery - Sort div by class using data()

Hi, is it possible to sort div by using the data function? html <div id="gp_21" class="line">one</div> <div id="gp_35" class="line">two</div> <div id="gp_11" class="line">three</div> <div id="gp_29" class="line">four</div> <hr /> <div id="check"></div> js $(document).ready(function rt() { $('#gp_21').data("rtt", { age: '25135...

Parallelized sorting algorithm, a good choice

Hello buddies! I wanna implement a fast algorithm for a homework, but using parallel processing for this task. I heard that the parallel version of Quicksort is the best choice, but I'm not sure of this... maybe Heapsort is a good idea. Which algorithm do you think is the best one for a parallelized environment, and why? Regards. ...

How do I map (and sort) values from a hash of hashes?

I have a hash of hashes, like so: %hash = ( a => { b => 1, c =>2, d => 3}, a1 => { b => 11, c =>12, d => 13}, a2 => { b => 21, c =>22, d => 23} ) I want to extract the "b" element and put it into an array. Right now, I am looping through the hash to do this, but I think I can improve efficiency slightly by using...

How to sort a query result array

Hi, I have a array with results from a query from regular tables, for example: id | Name | Department | Location | Email | Phone | Type | ..........and so on I have the results in a query array, I can get the default query sorted, but I would like to ability to be able to resort that array as needed without having to keep re-reading d...

How to sort rows in a text file in Perl?

I have a couple of text files (A.txt and B.txt) which look like this (might have ~10000 rows each) processa,id1=123,id2=5321 processa,id1=432,id2=3721 processa,id1=3,id2=521 processb,id1=9822,id2=521 processa,id1=213,id2=1 processc,id1=822,id2=521 I need to check if every row in file A.txt is present in B.txt as well (B.txt might have...

How can I parallel-ize an algorithm on a machine with multiple processors?

Intel Core2Duo, for example is supposed to have a single die but two cores. So, it should be possible to control what is processed on which core, which means that it is possible to instruct my algorithm to use the two cores in parallel. The question is how? Do I need to go down at the kernel level to do this, or is there a simpler wa...

Merge two ActiveRecord arrays and order by created_at

books = Book.find(:all) articles = Articles.find(:all) By reading from http://guides.rubyonrails.org/layouts_and_rendering.html I knew that I could do something like: <%= render :partial => [customer1, employee1, customer2, employee2] %> and it would use _customer and _employee partials as appropriate. So I want to do something lik...

Sorting Items in Rails Controller Method

I'm having an issue writing a controller action that takes Post ids passed as a parameter and sorts them into a specific order before publishing them. The Posts have a position attribute (I'm using acts_as_list for sorting), and are either published or unpublished (searchable with the named_scopes Post.published and Post.unpublished, ac...

sort an array base on key

i have an array like this: Array ( [0] => Array ( [title] => some title [time] => 1279231500 ) [1] => Array ( [title] => some title 2 [time] => 1279231440 ) [2] => Array ( [title] => some title 3 [time] => 127922...

solr: multiply score with a field

Hopefully an easy question: I have added some docs to the index, where every doc has a field prio, which is an integer between 1 and 5. There is also a text field for fulltext search. What I want: multiply the prio-value with the score value and order the docs by that result. what I tried: this and that :) last thing was q=whatever _va...

How print out the contents of a HashMap<String, String> in ascending order based on its values?

I have this HashMap that I need to print out in ascending order according to the values contained in it (not the keys). But the order when I print it out is seemingly random. What's the best way to print it out in ascending value order? Map<String, String> codes = new HashMap<String, String>(); codes.put("A1", "Aania"); codes.put("...

Is it faster to add to a collection then sort it, or add to a sorted collection?

If I have a Map like this: HashMap<Integer, ComparableObject> map; and I want to obtain a collection of values sorted using natural ordering, which method is fastest? (A) Create an instance of a sortable collection like ArrayList, add the values, then sort it: List<ComparableObject> sortedCollection = new ArrayList<ComparableObject...

Sorting an array

If I have an array of data, what is the best option for sorting them so they are displayed in ascending alphabetical order based on key 2 of the second array within each ArrayObject? Data ArrayObject::__set_state(array( 'job_category_filter_population' => ArrayObject::__set_state(array( 10225 => ArrayObject::__set_state...

Why 10 in the beginning of an ArrayList after Sort()

As the question says i have this problem. I know why it is in the beginning, because it is a 1 and a 0, so therefore its before 9 even after sorting. But, can it be in the right order with the lists sort() method? ...

For insert-performance consideration, should a clustered index on a timestamp be ascending or descending?

I just realized I have a clustered index on a Timestamp in descending order. I'm thinking about switching it to ascending, so that as new, ever-increasing timestamps are inserted, they are added to the end of the table. As it stands now, I suspect it has to add rows to the beginning of the table, and I wonder how SQL Server handles tha...

Order of List using Linq is not the same as sort

I would like to confirm this, I was trying to sort a List of my class using Linq. But it seems the order of the data was not ordering the same way when i used a sort function. Assume that the list contains 4 ComputeItem and all their A are set to 1, the B, C, D of all are set to zero. CASE 1: ItemList = ItemList .OrderByD...

is php sort better than mysql "order by" ?

Hi. I was wondering if, in terms of performance and considering a mysql select on a table with very very very many (> 1.000.000) records, is better sorting results with sql "order by" or sorting results after the query with classical programming sort algorithm ... someone has any suggestion? Tanks ...