Search Results

Search found 3659 results on 147 pages for 'sorted hash'.

Page 98/147 | < Previous Page | 94 95 96 97 98 99 100 101 102 103 104 105  | Next Page >

  • C# - How to implement multiple comparers for an IComparable<T> class?

    - by Gary Willoughby
    I have a class that implements IComparable. public class MyClass : IComparable<MyClass> { public int CompareTo(MyClass c) { return this.whatever.CompareTo(c.whatever); } etc.. } I then can call the sort method of a generic list of my class List<MyClass> c = new List<MyClass>(); //Add stuff, etc. c.Sort(); and have the list sorted according to my comparer. How do i specify further comparers to sort my collection different ways according to the other properties of MyClass in order to let users sort my collection in a number of different ways?

    Read the article

  • Sorting and aligning the contents of a text file in Python

    - by Emily Price
    In my program I have a text file that I read from and write to. However, I would like to display the contents of the text file in an aligned and sorted manner. The contents currently read: name, score name, score This is my code where the text file in read and printed: elif userCommand == 'V': print "High Scores:" scoresFile = open("scores1.txt", 'r') scores = scoresFile.read().split("\n") for score in scores: print score scoresFile.close() Would I have to convert this information into lists in order to be able to do this? If so, how do I go about doing this? Thank you

    Read the article

  • How to search for closest value in a lookup table?

    - by CSharperWithJava
    I have a simple one dimmensional array of integer values that represent a physical set of part values I have to work with. I then calculate and ideal value mathematically. How could I write an efficient search algorithm that will find the smallest abosulte difference from my ideal value in the array? The array is predetermined and constant, so it can be sorted however I need. Example Lookup array: 100, 152, 256, 282, 300 Searching for an ideal value of 125 would find 100 in the array, whereas 127 would find 152. The actual lookup array will be about 250 items long and never change.

    Read the article

  • NSSortdescriptor, finding the path to the key I wish to use for sorting.

    - by RickiG
    Hi I am using an NSSortdescriptor to sort a collection of NSArrays, I then came across a case where the particular NSArray to be sorted contains an NSDictionary who contains an NSDictionary. I would like to sort from the string paired with a key in the last dictionary. This is how I would reference the string: NSDictionary *productDict = [MyArray objectAtIndex:index]; NSString *dealerName = [[productDict objectForKey:@"dealer"] objectForKey:@"name"]; How would I use the dealerName in my NSSortdescriptor to sort the array? NSSortDescriptor * sortDesc = [[NSSortDescriptor alloc] initWithKey:/* ? */ ascending:YES]; sortedDealerArray = [value sortedArrayUsingDescriptors:sortDesc]; [sortDesc release]; Hope someone could help me a bit with how I go about sorting according to keys inside objects inside other objects:) Thank you.

    Read the article

  • Find recipes that can be cooked from provided ingridients

    - by skaurus
    Sorry for bad English :( Suppose i can preliminary organize recipes and ingredients data in any way. How can i effectively conduct search of recipes by user-provided ingredients, preferably sorted by max match - so, first going recipes that use maximum of provided ingridients and do not contain any other ingrs, after them recipes that uses less of provided set and still not any other ingrs, after them recipes with minimum additional requirements and so on? All i can think about is represent recipe ingridients like bitmasks, and compare required bitmask with all recipes, but it is obviously a bad way to go. And related things like Levenstein distance i don't see how to use here. I believe it should be quite common task...

    Read the article

  • How to correctly do SQL UPDATE with weighted subselect?

    - by luminarious
    I am probably trying to accomplish too much in a single query, but have I an sqlite database with badly formatted recipes. This returns a sorted list of recipes with relevance added: SELECT *, sum(relevance) FROM ( SELECT *,1 AS relevance FROM recipes WHERE ingredients LIKE '%milk%' UNION ALL SELECT *,1 AS relevance FROM recipes WHERE ingredients LIKE '%flour%' UNION ALL SELECT *,1 AS relevance FROM recipes WHERE ingredients LIKE '%sugar%' ) results GROUP BY recipeID ORDER BY sum(relevance) DESC; But I'm now stuck with a special case where I need to write the relevance value to a field on the same row as the recipe. I figured something along these lines: UPDATE recipes SET relevance=(SELECT sum(relevance) ...) But I have not been able to get this working yet. I will keep trying, but meanwhile please let me know how you would approach this?

    Read the article

  • Is there a way to set an int to 001

    - by H.aLFaRSi
    i need to set an integer to start from 001 instead of only 1 int iNumber = 001; NSLog(@"%d",iNumber); // this is logging 1 instead of 001 is there a possible way to make it 001 ? [UPDATED] i need this because i`m creating an NSMutableArray from NSUserDefaults, after that I'm sorting the array using NSSortDescriptor. the problem is because i can't set the int to start from 001 the array i sorted like this 0, 10, 11, 12, 1, 2, 3, 4, 5, 6, 7, 8, 9. More Code explained NSString *name = @"Name"; NSUserDefaults *MainArray = [NSUserDefaults standardUserDefaults]; NSString *Temp = [NSString stringWithFormat:@"%@%d", name,MainNumber]; [MainArray setObject:@"test" forKey:Temp]; [MainArray synchronize]; NSLog(@"%@",Temp); MainNumber++; the above code will save it like this : Name1,Name2,Name3.... i need it to be Name001, Name002, Name003 ....... thank you in advance :)

    Read the article

  • Why specifcially in my example does this "too much recursion" error occur in my JavaScript?

    - by alex
    I have been looking into this for a little while now. I have a gallery on my page, that uses Ariel Flesler's scrollTo plugin. It works fine on the home page, but not on the Contact page. In Firefox, I get the error... Too much recursion I have sorted through as much code as possible and set breakpoints in a few places. I am pretty sure it is something to do with the plugin (specifically, when it is called in the click handler). For your convenience, I am using the unpacked versions of jQuery and scrollTo plugin. What on earth am I doing wrong? Thanks for your time.

    Read the article

  • Initial state of autoCreateRowSorter in Swing JTable

    - by Nazgulled
    I have this JTable on my Swing app with the autoCreateRowSorter enabled. My table only has 3 columns, two strings and one int, it works well for all of them when I click the column headers. However, I'm looking for way to do it programatically. I wanted to set the "initial state" for this table. With the Windows look and feel, the column header (when sorted) has a little arrow showing the sort order. But at startup that doesn't show, I have to do one initial click. How can I do that by code?

    Read the article

  • Ruby on Rails: how to sort data in an array of active record objects right before iterating?

    - by DerNalia
    What is the best way to sort an array of active record objects by by a field? This array is a field of an object, link_pages, and I want it sorted by the field "sequence" <% @menu_bar.link_pages.each do |lp| %> <li id="page_<%= lp.id%>" class="ui-state-default"> <span class="ui-icon ui-icon-arrowthick-2-n-s"></span> <font size=5><%= lp.name %></font> | <%= link_to "remove", :controller => "admin/menu_bars", :action => :remove_page_from_menu, :page => lp.id, :id => @menu_bar.id %> </li> <% end %> maybe there is a way to do @menu_bar.link_pages.sort_by_sequence.each do .... that would be slick... but I just don't know.

    Read the article

  • Auto-fill the current date if the previous row was empty

    - by replax
    I have a spreadsheet sorted by dates. Everyday, I enter new data into it. After each day, I leave one row empty before starting the next day. Example: 20.09.12 XXXXX XXXXX XXXXX XXXX XXXXX XXXX XXXXX XX XX XXXXX XX XXXX 21.09.12 XXX XXXXX XXX XXXX X XXXX XXXX XXX 22.09.12 XXXX XX XXXX XXXX So I want excel to always fill in the current date whenever I enter data after one blank row, but obviously the dates shall stay the same - not be updated to the current date whenever I open excel. I am using Excel 2007 and while non vba ideas are preferred, vba is not a problem either!

    Read the article

  • How to find the largest square in the number (Java)

    - by Ypsilon IV
    Hello everyone, I want to find the largest square in the number, but I am stuck at some point. I would really appreciate some suggestions. This is what I've done so far: I take the number on the input, factorize into prime numbers, and put the sequence of prime numbers to ArrayList. Numbers are sorted, in a sense, thus the numbers in the sequence are increasing. For example, 996 is 2 2 3 83 1000 is 2 2 2 5 5 5 100000 is 2 2 2 2 2 5 5 5 5 5 My idea now is to count number of occurrences of each elements in the sequence, so if the number of occurrences is divisible by two, then this is the square. In this way, I can get another sequence, where the right most element divisible by two is the largest square. What is the most efficient way to count occurrences in the ArrayList? Or is there any better way to find the largest square? Many thanks in advance!

    Read the article

  • Sorting in Matlab

    - by smichak
    Hi, I would like to sort elements in a comma-separated list. The elements in the list are structs and I would like the list to be sorted according to one of the fields in the struct. For example, given the following code: L = {struct('obs', [1 2 3 4], 'n', 4), struct('obs', [6 7 5 3], 'n', 2)}; I would want to have a way to sort L by the field 'n'. Matlab's sort function only works on matrices or arrays and on lists of strings (not even lists of numbers). Any ideas on how that may be achieved? Thanks, Micha

    Read the article

  • unconventional sorting in excel

    - by I__
    i have a list like this: G05 G03 F02 F06 G10 A03 A11 E10 E05 C11 C03 D03 A12 C12 F05 H03 C08 G02 D10 B12 C10 D11 C02 E11 E02 E03 H11 A08 D05 F04 A04 H07 D04 B07 F12 E04 B03 H05 C06 F08 C09 E08 G12 C04 B05 H09 A07 E09 C07 G07 G09 A06 D09 E07 E12 G04 A10 H02 G08 B06 B09 D06 F07 G06 A09 H06 D07 H04 H10 F10 B02 B10 F03 F11 D08 B11 B08 D12 H08 A05 i need it sorted in the following manner: A03, B03, C03....A04, B04, C04.....A11, B11, C11........ the conventional sort can be done like this: ActiveWorkbook.Worksheets("2871P1").Sort.SortFields.Add Key:=Range("D20:D99") _ , SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:=xlSortNormal With ActiveWorkbook.Worksheets("2871P1").Sort .SetRange Range("D20:E99") .Header = xlGuess .MatchCase = False .Orientation = xlTopToBottom .SortMethod = xlPinYin .Apply End With however with this method, we are going to get A01, A02, A03 etc..., but this is not what i need

    Read the article

  • How can I achive this effect jQuery? or can it be done with CSS?

    - by Charles Marsh
    Hello All, Is it possible to switch HTML on click? I have an index page with a large image on the front. Under the image there is four links. When the cursor rolls over the link I would like a small tool tip to appear. Then when the clicks the link I want the large Image to change and some extra HTML to appear over it. (just a small content box) The tooltip I think I have sorted using Jquery but I'm not sure how I can change the image [b]AND[/b] add a small content box over the image. Thanks in advanced everyone.

    Read the article

  • group by, order by, with join

    - by Scarface
    Hey guys, quick question, I have this query, and I am trying to get the latest comment for each topic and then sort those results in descending order (therefore one comment per topic). I have what I think should work, but my join always messes my results up. Somehow, it seems to have sorted the end results properly, but has not taken the latest comment from each topic instead it seems to have just taken a random comment. If anyone has any ideas, would really appreciate any advice SELECT * FROM comments JOIN topic ON topic.topic_id=comments.topic_id WHERE topic.creator='admin' GROUP BY comments.topic_id ORDER BY comments.time DESC table comments is structured like id time user message topic_id table topic is structured like topic_id subject_id topic_title creator timestamp description

    Read the article

  • Complexity in using Binary search and Trie

    - by user121196
    given a large list of alphabetically sorted words in a file,I need to write a program that, given a word x, determines if x is in the list. Preprocessing is ok since I will be calling this function many times over different inputs. priorties: 1. speed. 2. memory I already know I can use (n is number of words, m is average length of the words) 1. a trie, time is O(log(n)), space(best case) is O(log(n*m)), space(worst case) is O(n*m). 2. load the complete list into memory, then binary search, time is O(log(n)), space is O(n*m) I'm not sure about the complexity on tri, please correct me if they are wrong. Also are there other good approaches?

    Read the article

  • Any way to avoid a filesort when order by is different to where clause?

    - by Julian
    I have an incredibly simple query (table type InnoDb) and EXPLAIN says that MySQL must do an extra pass to find out how to retrieve the rows in sorted order. SELECT * FROM `comments` WHERE (commentable_id = 1976) ORDER BY created_at desc LIMIT 0, 5 exact explain output: table select_type type extra possible_keys key key length ref rows comments simple ref using where; using filesort common_lookups common_lookups 5 const 89 commentable_id is indexed. Comments has nothing trick in it, just a content field. The manual suggests that if the order by is different to the where, there is no way filesort can be avoided. http://dev.mysql.com/doc/refman/5.0/en/order-by-optimization.html I also tried order by id as well as it's equivalent but makes no difference, even if I add id as an index (which I understand is not required as id is indexed implicitly in MySQL). thanks in advance for any ideas!

    Read the article

  • Reload a div with jquery, but not with .load

    - by zomboble
    I need to reload a div on a page on click. So far I have this: <div id="next"><a id="nextC" href="#">NEXT TESTIMONIAL</a></div><!-- END #next --> And the js $('#nextC').click(function(){ $('#atestimonial').load('/ #atestimonial'); evt.preventDefault(); }); I am using wordpress and I have a method sorted for pulling data into the div atestimonial. All I need to do is refresh it on click, doesnt matter about loading a page in. Can this be done?

    Read the article

  • Sorting a meta-list by first element of children lists in Python

    - by thismachinechills
    I have a list, root, of lists, root[child0], root[child1], etc. I want to sort the children of the root list by the first value in the child list, root[child0][0], which is an int. Example: import random children = 10 root = [[random.randint(0, children), "some value"] for child in children] I want to sort root from greatest to least by the first element of each of it's children. I've taken a look at some previous entries that used sorted() and a lamda function I'm entirely unfamiliar with, so I'm unsure of how to apply that to my problem. Appreciate any direction that can by given Thanks

    Read the article

  • TeamCity build triggers don't automatically run

    - by Phil.Wheeler
    I've been playing around with and learning a bit about TeamCity and have the server correctly set up with my .Net MVC project committed in Subversion successfully and build configurations and triggers sorted to kick off when any changes are committed to the repository. TeamCity polls on its default time period and is picking up that changes have been committed, but it is adding these to the queue without actually ever running them. I have to manually click the "Run" button to kick them off. What setting do I need to change in order to ensure that any new changes are automatically run?

    Read the article

  • Multiple mod rewrites in .htaccess

    - by Bob
    I want the following rules but I don't seem to get the right setup. <domain>/training-courses/ both with or without the slash at the end it should go to: <domain>/?index.php?page=training-courses and for each variable extra after this I want it to behave like this: <domain>/training-courses/success/another-value/and-yet-another/ to <domain>/?index.php?page=training-courses&val1=success&val2=another-value&val3=and-yet-another-value If it's not possible to have the option for unlimited leading variables, i'd like to have at least 2 variables after the page variable Is this possible? and how do I get this sorted out? I have this so far: RewriteEngine On RewriteRule ^test/([^/]*)/$ /test/index.php?pagina=$1&val1=$2 RewriteRule ^test/([^/]*)$ /test/index.php?pagina=$1&val1=$2 RewriteRule ^test/([^/]*)/([^/]*)/$ /test/index.php?pagina=$1&val1=$2 RewriteRule ^test/([^/]*)/([^/]*)$ /test/index.php?pagina=$1&val1=$2 RewriteRule ^test/([^/]*)/([^/]*)/([^/]*)/$ /test/index.php?pagina=$1&val1=$2&val2=$3 RewriteRule ^test/([^/]*)/([^/]*)/([^/]*)$ /test/index.php?pagina=$1&val1=$2&val2=$3

    Read the article

  • Generate MySQL data dump in SQL from PHP

    - by Álvaro G. Vicario
    I'm writing a PHP script to generate SQL dumps from my database for version control purposes. It already dumps the data structure by means of running the appropriate SHOW CREATE .... query. Now I want to dump data itself but I'm unsure about the best method. My requirements are: I need a record per row Rows must be sorted by primary key SQL must be valid and exact no matter the data type (integers, strings, binary data...) Dumps should be identical when data has not changed I can detect and run mysqldump as external command but that adds an extra system requirement and I need to parse the output in order to remove headers and footers with dump information I don't need (such as server version or dump date). I'd love to keep my script as simple as I can so it can be hold in an standalone file. What are my alternatives?

    Read the article

  • thinking sphinx ordering by mixing capitals and lower case

    - by miccet
    I have a rails application that is using thinking_sphinx for the searching. My problem is that the result returned is sorted with capitals first and lower case after it at the bottom. I'd like to mix them so that both 'A' and 'a' comes before 'B'. This is the method I'm using: Company.search(query, :star => true, :page => params[:page], :per_page => 20, :order => :name, :sort_mode => :asc)

    Read the article

  • What's the best way to return a subset of a list

    - by Pikrass
    I have a list of tasks. A task is defined by a name, a due date and a duration. My TaskManager class handles a std::list<Task> sorted by due date. It has to provide a way to get the tasks due for a specific date. How would you implement that ? I think a good way (from API point of view) would be to provide a std::list<Task>::iterator pair. So I would have a TaskManager::begin(date) method. Do you think this method should get the iterator by iterating from the start of the list until it finds the first task due on that date, or by getting it from a std::map<date, std::list<Task>::iterator> (but then we have to keep it up-to-date when adding or removing tasks) ? And then, how could I implement the TaskManager::end(date) method ?

    Read the article

< Previous Page | 94 95 96 97 98 99 100 101 102 103 104 105  | Next Page >