I'm counting the frequency of word occurances and would like to return
a key/value list sorted descending by frequency.
So I need to quickly see if a word (key) is in the list, but later
sort the list descending by values.
Any ideas on how to do this efficiently?
Thanks,
Jim 3 6163
Jim,
I think that the datatable with primary keys can exactly do what you want.
\\\just typed in, nothing checked
Dim dt As New DataTable
Dim keys(0) As DataColumn
dt.Columns.Add("Key")
dt.Columns.Add("Value")
keys(0) = dt.Columns(0)
dim dvValues as dataview(dt)
dv.sort = "Value"
etc
etc
///
You can use the dt.rows.find to find a key and the dv with the select for
the value.
I hope this helps?
Cor
Jim Adams" <ji*******@hotmail.com> I'm counting the frequency of word occurances and would like to return a key/value list sorted descending by frequency.
So I need to quickly see if a word (key) is in the list, but later sort the list descending by values.
Any ideas on how to do this efficiently?
Thanks,
Jim
Hi Jay,
Thanks for the tip.
-Jim
"Jay B. Harlow [MVP - Outlook]" <Ja************@msn.com> wrote in message news:<er**************@TK2MSFTNGP11.phx.gbl>... Jim, Unfortunately the Framework has no predefined classes that do that, however you can create a custom collection that encapsulates a Hashtable to allow key/value, and an ArrayList that you can sort to return descending values.
There are any number of ways to implement this depending on what the requirements of your program are.
1. Use a DictionaryBase with a method that populates & sorts the ArrayList as needed. 2. Use a DictionaryBase with a private field for the ArrayList. The Add method would add the object to both collections. 3. Use a CollectionBase with a private field for a HashTable. The Add method would add the object to both collections. 4. Create a custom object that contains both a HashTable & ArrayList.
Note in #2, #3 & #4 above I would use an insertion sort to maintain a sorted array as I added elements...
Hope this helps Jay
"Jim Adams" <ji*******@hotmail.com> wrote in message news:49**************************@posting.google.c om... I'm counting the frequency of word occurances and would like to return a key/value list sorted descending by frequency.
So I need to quickly see if a word (key) is in the list, but later sort the list descending by values.
Any ideas on how to do this efficiently?
Thanks,
Jim
Hi Cor,
Thanks for the tip.
Jim
"Cor Ligthert" <no************@planet.nl> wrote in message news:<ON**************@tk2msftngp13.phx.gbl>... Jim,
I think that the datatable with primary keys can exactly do what you want.
\\\just typed in, nothing checked Dim dt As New DataTable Dim keys(0) As DataColumn dt.Columns.Add("Key") dt.Columns.Add("Value") keys(0) = dt.Columns(0) dim dvValues as dataview(dt) dv.sort = "Value" etc etc ///
You can use the dt.rows.find to find a key and the dv with the select for the value.
I hope this helps?
Cor
Jim Adams" <ji*******@hotmail.com>
I'm counting the frequency of word occurances and would like to return a key/value list sorted descending by frequency.
So I need to quickly see if a word (key) is in the list, but later sort the list descending by values.
Any ideas on how to do this efficiently?
Thanks,
Jim This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Nova's Taylor |
last post by:
Hi folks,
I am a newbie to Python and am hoping that someone can get me started
on a log parser that I am trying to write.
The log is an ASCII file that contains a process identifier (PID),...
|
by: Brett |
last post by:
I have two arrays and i wish to sort the first one numerically, but after
sorting, I would like the second array to be in the same matching order as
the first array.
ie.
@l1={3,1,2};...
|
by: Christian Gruber |
last post by:
dear NG,
I have a problem sorting the values of a container,
multimap<int, pair<int, double> > map;
where the key element is the first column
and part of the value is the second column.
1 ...
|
by: Mike Ruskai |
last post by:
Something like the following does not sort the results:
select * from properties where match(location) against('"main st"' in boolean
mode) order by location;
The results are not sorted by...
|
by: lok |
last post by:
i have a class:
template <class T1, class T2>
class CPairMapping {
public:
typedef std::pair<T1, T2> ValuePair_t;
typedef std::vector<ValuePair_t> ValueList_t;
typedef std::binary_function<...
| |
by: qazmlp |
last post by:
I have got a sorted vector of pair<string, string> which contains
the following entries:
first string second string
Pair-1: 121721234567890 str1One
Pair-2: 121721234567890 str1
Pair-3:...
|
by: Jae |
last post by:
Hi
I wonder how can I implement the STL map sorting by value.
For example, I have a map m
map<int, intm;
m = 10;
m = 5;
m = 6;
|
by: karen.b.lin |
last post by:
I've created a multimap of pointers. The sort order by key seems
messed up.
ex:
std::multimap<BOMBImntRT*, BOMBPortfolio*undPortMap;
I did not try to create multimap of objects instead,...
|
by: jason.cipriani |
last post by:
How can I use my own custom comparison function with
std::list::sort()? The only call to sort() I see does not take a
predicate argument.
Specifically, I have:
list<pair<double,MyType ...;
...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
| |
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
| | |