Search Results

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

Page 52/147 | < Previous Page | 48 49 50 51 52 53 54 55 56 57 58 59  | Next Page >

  • Suitable GUI for sorting rows at database level and/or WYSIWYG level?

    - by Kristoffer
    Consider an Explorer-like list view with a number of columns. The data is fetched from a database, and the rows can be sorted by clicking the column headers. When you click column A, you expect the fetched data to be sorted by A - at the database level ("ORDER BY" at the selected column). However, sometimes it is desirable to sort the data presented in the GUI - the visible data (WYSIWYG). How do you combine these two? E.g. How do you allow the user to sort both the fetched data and the data visible in the GUI? Have you seen a GUI that solves this elegantly?

    Read the article

  • Indexing vs. no indexing when inserting records

    - by jbu
    I have a few questions about whether or not it would be best to not use indexing. BACKGROUND: My records have a timestamp attribute, and the records will be inserted in order of their timestamps (i.e., inserted chronologically). QUESTIONS: If I DON'T use indexing is it typical for the database to insert the records in the order that they were inserted? If answer to #1 is yes, when I do a "SELECT .. WHERE timestamp X" type query will the database be efficient at it, or will it have to go through every single record since it isn't indexed? I would assume if there were no index, the database would not "know" that the records were inserted in sorted order and could not, therefore, make use of sorted property of the database. I assume a clustered index would be best for these types of records & their inserts. Please let me know what you guys think. Thanks, jbu

    Read the article

  • multicolumn sorting of WinForms DataGridView

    - by Bi
    I have a DataGridView in a windows form with 3 columns: Serial number, Name, and Date-Time. The Name column will always have either of the two values: "name1" or "name2". I need to sort these columns such that the grid displays all the rows with name values in a specific order (first display all the "name1" rows and then all the "name2" rows). Within the "name1" rows, I want the rows to be sorted by the Date-Time. Please note programmatically, all the 3 columns are strings. For example, if I have the rows: 01 |Name1 | 2010-05-05 10:00 PM 02 |Name2 | 2010-05-02 08:00 AM 03 |Name2 | 2010-05-01 08:00 AM 04 |Name1 | 2010-05-01 11:00 AM 05 |Name1 | 2010-05-04 07:00 AM needs to be sorted as 04 |Name1 | 2010-05-01 11:00 AM 05 |Name1 | 2010-05-04 07:00 AM 01 |Name1 | 2010-05-05 10:00 PM 03 |Name2 | 2010-05-01 08:00 AM 02 |Name2 | 2010-05-02 08:00 AM I am not sure how to go about using the below: myGrid.Sort(.....,ListSortDirection.Ascending)

    Read the article

  • PyQt: How to keep QTreeView nodes correctly expanded after a sort

    - by taynaron
    I'm writing a simple test program using QTreeModel and QTreeView for a more complex project later on. In this simple program, I have data in groups which may be contracted or expanded, as one would expect in a QTreeView. The data may also be sorted by the various data columns (QTreeView.setSortingEnabled is True). Each tree item is a list of data, so the sort function implemented in the TreeModel class uses the built-in python list sort: self.layoutAboutToBeChanged.emit() self.rootItem.childItems.sort(key=lambda x: x.itemData[col], reverse=order) for item in self.rootItem.childItems: item.childItems.sort(key=lambda x: x.itemData[col], reverse=order) self.layoutChanged.emit() The problem is that whenever I change the sorting of the root's child items (the tree is only 2 levels deep, so this is the only level with children) the nodes aren't necessarily expanded as they were before. If I change the sorting back without expanding or collapsing anything, the nodes are expanded as before the sorting change. Can anyone explain to me what I'm doing wrong? I suspect it's something with not properly reassigning QModelIndex with the sorted nodes, but I'm not sure.

    Read the article

  • Sorting a nodeset before passing to xsl:for-each

    - by Zack Mulgrew
    I have a situation where loop through a sorted nodeset and apply a template on each of the nodes: <div id="contractscontainer"> <xsl:for-each select="document"> <xsl:sort select="content[@name='ClientName']/text()" /> <xsl:apply-templates select="." mode="client-contract" /> </xsl:for-each> </div> I want to do something special with the "first" 5 nodes in the node set and render them nested element. The problem is that they need to be in the same order as if they were sorted (as they are in the loop). I had planned on doing this by using two xsl:for-each elements, each with the correct nodes selected from the set. I can't do this, however, because they need to be sorted before I can select the "first" 5. Example: <div id="contractscontainer"> <div class="first-five"> <xsl:for-each select="document[position() < 6]"> <xsl:sort select="content[@name='ClientName']/text()" /> <xsl:apply-templates select="." mode="client-contract" /> </xsl:for-each> </div> <div class="rest-of-them"> <xsl:for-each select="document[position() > 5]"> <xsl:sort select="content[@name='ClientName']/text()" /> <xsl:apply-templates select="." mode="client-contract" /> </xsl:for-each> </div> </div> I don't think this will work because I'm selecting the nodes by position before sorting them, but I can't use xsl:sort outside of the xsl:for-each. Am I approaching this incorrectly?

    Read the article

  • Sort NSArray of custom objects based on sorting of another NSArray of strings

    - by Nic Hubbard
    I have two NSArray objects that I would like to be sorted the same. One contains NSString objects, the other custom Attribute objects. Here is what my "key" NSArray looks like: // The master order NSArray *stringOrder = [NSArray arrayWithObjects:@"12", @"10", @"2", nil]; The NSArray with custom objects: // The array of custom Attribute objects that I want sorted by the stringOrder array NSMutableArray *items = [[NSMutableArray alloc] init]; Attribute *attribute = nil; attribute = [[Attribute alloc] init]; attribute.assetID = @"10"; [items addObject:attribute]; attribute = [[Attribute alloc] init]; attribute.assetID = @"12"; [items addObject:attribute]; attribute = [[Attribute alloc] init]; attribute.assetID = @"2"; [items addObject:attribute]; So, what I would like to do is use the stringOrder array to determine the sorting of the items array of custom objects. How can I do this?

    Read the article

  • question about merge algorithm

    - by davit-datuashvili
    hi i have question i know that this question is somehow nonsense but let see i have code to merge two sorted array in a one sorted array here is code in java public class Merge { public static void main(String[]args){ int a[]=new int[]{7,14,23,30,35,40}; int b[]=new int[]{5,8,9,11,50,67,81}; int c[]=new int[a.length+b.length]; int al=0; int bl=0; int cl=0; while (al<a.length && bl<b.length) if (a[al]<b[bl]) c[cl++]=a[al++]; else c[cl++]=b[bl++]; while (al<a.length) c[cl++]=a[al++]; while (bl<b.length) c[cl++]=b[bl++]; for (int j=0;j<c.length;j++){ System.out.println(c[j]); } } } question is why does not work if we write here {} brackets while (al } ?

    Read the article

  • Group keywords by site

    - by Skudd
    I am finding a lot of useful help here today, and I really appreciate it. This should be the last one for the day: I have a list of the top 10 keywords per site, sorted by visits, by date. The records need to be sorted as follows (excuse the formatting): 2010-05 2010-04 site1.com keyword1 apples wine keyword1 visits 100 12 keyword2 oranges water keyword2 visits 99 10 site2.com keyword1 blueberry cornbread keyword1 visits 90 100 keyword2 squares biscuits keyword2 visits 80 99 Basically what I need to accomplish involves grouping, but I can't seem to figure it out. Am I heading down the right path, or is there another way to achieve this, or is it just impossible?

    Read the article

  • How to combine elements of a list

    - by Addie
    I'm working in c#. I have a sorted List of structures. The structure has a DateTime object which stores month and year and an integer which stores a value. The list is sorted by date. I need to traverse the list and combine it so that I only have one instance of the structure per date. For example: My initial list would look like this: { (Apr10, 3), (Apr10, 2), (Apr10, -3), (May10, 1), (May10, 1), (May10, -3), (Jun10, 3) } The resulting list should look like this: { (Apr10, 2), (May10, -1), (Jun10, 3) } I'm looking for a simple / efficient solution. The struct is: class CurrentTrade { public DateTime date; public int dwBuy; } The list is: private List<CurrentTrade> FillList

    Read the article

  • Sorting the data returned by a database

    - by Rishabh Ohri
    hi all, In our project we have a requirement that when a set of records are returned by the database the records should be sorted with respect to the TITLE field in the record. The records will have to be sorted alphabetically but if the title of a record has a number in it then it should come after the records whose title only consists of alphabets. Details: we are using SQL Server , and c#. The data from the database comes to an Entity class whic forwards the data to other layers. So, What will be the possible and effective solution for this requirement.

    Read the article

  • The dictionary need to add every word in SpellingMistakes and the line number but it only adds the l

    - by Will Boomsight
    modules import sys import string Importing and reading the files form the Command Prompt Document = open(sys.argv[1],"r") Document = open('Wc.txt', 'r') Document = Document.read().lower() Dictionary = open(sys.argv[2],"r") Dictionary = open('Dict.txt', 'r') Dictionary = Dictionary.read() def Format(Infile): for ch in string.punctuation: Infile = Infile.replace(ch, "") for no in string.digits: Infile = Infile.replace(no, " ") Infile = Infile.lower() return(Infile) def Corrections(Infile, DictWords): Misspelled = set([]) Infile = Infile.split() DictWords = DictWords.splitlines() for word in Infile: if word not in DictWords: Misspelled.add(word) Misspelled = sorted(Misspelled) return (Misspelled) def Linecheck(Infile,ErrorWords): Infile = Infile.split() lineno = 0 Noset = list() for line in Infile: lineno += 1 line = line.split() for word in line: if word == ErrorWords: Noset.append(lineno) sorted(Noset) return(Noset) def addkey(error,linenum): Nodict = {} for line in linenum: Nodict.setdefault(error,[]).append(linenum) return Nodict FormatDoc = Format(Document) SpellingMistakes = Corrections(FormatDoc,Dictionary) alp = str(SpellingMistakes) for word in SpellingMistakes: nSet = str(Linecheck(FormatDoc,word)) nSet = nSet.split() linelist = addkey(word, nSet) print(linelist) # # for word in Nodict.keys(): # Nodict[word].append(line) Prints each incorrect word on a new line

    Read the article

  • In Haskell, how can you sort a list of infinite lists of strings?

    - by HaskellNoob
    So basically, if I have a (finite or infinite) list of (finite or infinite) lists of strings, is it possible to sort the list by length first and then by lexicographic order, excluding duplicates? A sample input/output would be: Input: [["a", "b",...], ["a", "aa", "aaa"], ["b", "bb", "bbb",...], ...] Output: ["a", "b", "aa", "bb", "aaa", "bbb", ...] I know that the input list is not a valid haskell expression but suppose that there is an input like that. I tried using merge algorithm but it tends to hang on the inputs that I give it. Can somebody explain and show a decent sorting function that can do this? If there isn't any function like that, can you explain why? In case somebody didn't understand what I meant by the sorting order, I meant that shortest length strings are sorted first AND if one or more strings are of same length then they are sorted using < operator. Thanks!

    Read the article

  • Is it possible to use array_shift() in PHP and get the key?

    - by alex
    I have a list of files in an array where the filename is the key and the value is the last modified date in seconds. They are sorted from oldest to newest. The files are glob()'d in, and then sorted this way using asort($fileNameToLastModified, SORT_NUMERIC); I use array_shift() to get the oldest file. Unfortunately, it seems to be giving me the value, and there doesn't seem to be a way to get the key. Would the only way to do that be something like this? $keys = array_keys($fileNameToLastModified); $oldest = array_shift($keys); array_shift($fileNameToLastModified); // to manually chop the first array member off too. Or is there a built in? Thanks

    Read the article

  • Is it possible to use array_shift() in PHP and get the key?

    - by alex
    I have a list of files in an array where the filename is the key and the value is the last modified date in seconds. They are sorted from oldest to newest. The files are glob()'d in, and then sorted this way using asort($fileNameToLastModified, SORT_NUMERIC); I use array_shift() to get the oldest file. Unfortunately, it seems to be giving me the value, and there doesn't seem to be a way to get the key. Would the only way to do that be something like this? $keys = array_keys($fileNameToLastModified); $oldest = array_shift($keys); array_shift($fileNameToLastModified); // to manually chop the first array member off too. Or is there a built in? Thanks

    Read the article

  • Sorting a vector of (double precision) reals and obtain their order

    - by Philipp
    Hello everyone, in C++ would like to sort a lengthy (2^20) vector of reals, obviously sort() does the trick. Having used R before I was used to the nice order() function which yields the permutation that leads to the sorted vector. Probably someone has done this in C++, maybe it's just my weak google-Fu that prevents me from finding it. And yeah, obivously my C++ newbness could stop me from spotting something straightforward. Example: x = {24, 55, 22, 1} then the permutation perm = {3, 2, 0, 1} maps the original x to the sorted x in ascending order. I can probably implement some bubble sort which does not only sort x but performs the same transpositions on the vector {0,1,2,...} and outputs both, but I believe someone must have thought about it and especially have done it efficiently. Thank you very much, Philipp

    Read the article

  • What is the most efficient way to store a mapping "key -> event stream"?

    - by jkff
    Suppose there are ~10,000's of keys, where each key corresponds to a stream of events. I'd like to support the following operations: push(key, timestamp, event) - pushes event to the event queue for key, marked with the given timestamp. It is guaranteed that event timestamps for a particular key are pushed in sorted or almost sorted order. tail(key, timestamp) - get all events for key since the given timestamp. Usually the timestamp requests for a given key are almost monotonically increasing, almost synchronously with pushes for the same key. This stuff has to be persistent (although it is not absolutely necessary to persist pushes immediately and to keep tails with pushes strictly in sync), so I'm going to use some kind of database. What is the optimal kind of database structure for this task? Would it be better to use a relational database, a key-value storage, or something else?

    Read the article

  • Trapping events within list box item templates in WPF

    - by AC
    I've got listbox that employs an item template. Within each item in the list, as defined in the template there is a button. When the user clicks the button I change a value in the data source that defines the sort order of the list. Changing the datasource is not a problem as this is working just fine within my application template. However my next step is to reload the listbox with the new sorted data source. I've tried doing this from the tempalte but it apparently doesn't have access (or I can't figure out how to get access) to the parent elements so I can reset the .ItemSource property with a newly sorted data source. Seems like this is possible but the solution is eluding me :(

    Read the article

  • retrieve comma delimited data from a field in using SQL

    - by Nichols
    I've created a form in php that collects basic information. I have a list box that allows multiple items selected (ie housing, rent, food, water). If multiple items are selected they are stored in a field called Needs seperated by a comma. I have created a report ordered by the persons needs. The people who only have one need are sorted correctly, but the people who have multiple are sorted exactly as the string passed to the database (ie. housing, rent, food, water) -- which is not what i want. Is there a way to seperate the multiple values in this field using SQL to count each need instance/occurance as 1 so that there are no comma delimitations shown in the results? CLICK FOR EXAMPLE

    Read the article

  • multi column sorting of datagrid view:

    - by Bi
    I have a datagridview in a windows form with 3 columns: Serial number, Name and Date-Time. The Name column will always have either of the two values: "name1" or "name2". I need to sort these columns such that the grid displays all the rows with name values in a specific order (first display all the "name1" rows and then all the "name2" rows). Within the "name1" rows, I want the rows to be sorted by the Date-Time. Please note programmatically, all the 3 columns are strings. For example, if I have the rows: 01 |Name1 | 2010-05-05 10:00 PM 02 |Name2 | 2010-05-02 08:00 AM 03 |Name2 | 2010-05-01 08:00 AM 04 |Name1 | 2010-05-01 11:00 AM 05 |Name1 | 2010-05-04 07:00 AM needs to be sorted as 04 |Name1 | 2010-05-01 11:00 AM 05 |Name1 | 2010-05-04 07:00 AM 01 |Name1 | 2010-05-05 10:00 PM 03 |Name2 | 2010-05-01 08:00 AM 02 |Name2 | 2010-05-02 08:00 AM I am not sure how to go about using the below: myGrid.Sort(.....,ListSortDirection.Ascending)

    Read the article

  • top-k selection/merge

    - by tcurdt
    I have n sorted lists. These lists are quite long (300000+ tuples). Selecting the top 10 of the individual lists is of course trivial - they are right at the head of the lists. Where it gets more interesting is when I want the top 10 of all the sorted lists. The question is whether there is an algorithm to calculate the combined top 10 having the correct order while cutting off the long tail of the lists. The goal is to reduce the required space. And if there is: How does one find the limit where is is safe to cut? Note: The actual counts are not important. Only the order is.

    Read the article

  • calling a function from another function in python

    - by user1040503
    I have written this function that takes to strings in order to see if they are anagrams: def anagram_check(str_x, str_y): x = string1.replace(" ","") y = string2.replace(" ","") lower1 = x.lower() lower2 = y.lower() sorted1 = sorted(lower1) sorted2 = sorted(lower2) if sorted1 == sorted2: return True else: return False this function works fine, the problem is that now I need to use this function in another function in order to find anagrams in a text file. I want to print a list of tuples with all the anagrams in it. this is what i have done so far def anagrams_finder(words_num): anagrams = [] f = open("words.txt") a = list(f) list1 = ([s.replace('\n', '') for s in a]) list2 = ([i.lower() for i in list1]) list3 = list2[0:words_num] #number of words from text that need to be checked. for i in list3: .... I tried using for loops, while loops, appand.... but nothing seems to work. how can I use the first function in order to help me with the second? Please help...

    Read the article

  • Overriding rubies spaceship operator <=>

    - by ericsteen1
    I am trying to override rubies <= (spaceship) operator to sort apples and oranges so that apples come first sorted by weight, and oranges second, sorted by sweetness. Like so: module Fruity attr_accessor :weight, :sweetness def <=>(other) # use Array#<=> to compare the attributes [self.weight, self.sweetness] <=> [other.weight, other.sweetness] end include Comparable end class Apple include Fruity def initialize(w) self.weight = w end end class Orange include Fruity def initialize(s) self.sweetness = s end end fruits = [Apple.new(2),Orange.new(4),Apple.new(6),Orange.new(9),Apple.new(1),Orange.new(22)] p fruits #should work? p fruits.sort But this does not work, can someone tell what I am doing wrong here, or a better way to do this?

    Read the article

  • How can I merge two lists and sort them working in 'linear' time?

    - by Sergio Tapia
    I have this, and it works: # E. Given two lists sorted in increasing order, create and return a merged # list of all the elements in sorted order. You may modify the passed in lists. # Ideally, the solution should work in "linear" time, making a single # pass of both lists. def linear_merge(list1, list2): finalList = [] for item in list1: finalList.append(item) for item in list2: finalList.append(item) finalList.sort() return finalList # +++your code here+++ return But, I'd really like to learn this stuff well. :) What does 'linear' time mean?

    Read the article

  • Which data structure for List of objects + datagrid wiev

    - by Martin
    Hi, I have to develop a code which will store a list of objects, as example below 101, value 11, value 12, value 13 ...etc 102, value 21, value 22, value 23 ...etc 103, value 31, value 32, value 33 ...etc 104, value 41, value 42, value 43 ...etc Now, the difficulty is, that first column is an identifier, and whole table should always be sorted by it. Easy access to each element is required. Additionally, list should be easily updated, and extended by adding element at the end as well as in front and still keep being sorted by first column. Finally, I would like to be able to display values of the above in datagridview. What is most important is a performance of the implementation, as rows will be updated many times per second, and datagridview should be able to display all changes immediately. I was thinking about creating class for the values, and then a Dictionary but encountered a problem with displaying values in gridview. What would be the most optimal way of implementing the code? Thanks in advance Martin

    Read the article

< Previous Page | 48 49 50 51 52 53 54 55 56 57 58 59  | Next Page >