Suppose i have a List<Map<String,Object>>.
Map represents each row, with column key and column_value value.
Now i want to sort the list on basis of n columns.
Suppose columns are like this .. col1,col2....coln.
Now i want to sort like this.... order by col3 desc, col2 asc.
What do you think, should i sort the values at multiple phases? like, first sort the col3 as descending order then sort the col2 as ascending order...Or,i should do like this ..like calculate a comparing value using the hash codes of the values?
What should be mathematics logic? Could you help me?
3 1393 @dmjpro
There is no mathematics nor logic involved; whatever you're going to do with those maps it's going to be a mess. They have invented databases for that juggling; use them.
kind regards,
Jos
Actually our case is something else. So i need to do using Java.
Suppose n1,n2 in one row. 2nd row contains n1,n3.
Now n1,n2 can't generate a number which is greater than number generated by n1,n3 in same way (provided n2>n3)?
@dmjpro
Generates a number? What for? You need to write quite a messy Comparator and not hack your way through it by trying to assign magic constant values to every row. Why can't you use a database for this mess?
kind regards,
Jos
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Laurence Breeze |
last post by:
Is it possible to add a column to a table using the "alter table"
statement and specify where in the sequence of columns the new column
sits. If not is there any way to alter the order of columns...
|
by: Frederik |
last post by:
Hi all,
I'm building a C# application that uses a M$ Acces database. In one of
the queries I use something like the following:
SELECT id FROM mytable WHERE id IN (20, 12, 21, 14)
The result...
|
by: AdamM |
last post by:
Currently, my code reads from a database without knowing the order of the
columns like this:
string name = (string)datarow;
However, is there a way to write or do an INSERT back to a database...
|
by: Beowulf |
last post by:
I have the view below and if I use vwRouteReference as the rowsource
for a combo box in an MS Access form or run "SELECT * FROM
vwRouteReference" in SQL Query Analyzer, the rows don't come through...
|
by: hazz |
last post by:
is there a way to have a re-arrangeable list with an asp.net control ?
I would like to have a list of database table column values in an ordered
list initially loaded by their column order in the...
|
by: todd.freed |
last post by:
Hello. I'll make this quick - its quite a conundrum
I have the following markup
<MyNS:MyControl runat="server" id="myId"
CustomProperty1="value"
CustomProperty1="value"...
|
by: weetat.yeo |
last post by:
Hi all ,
I have sql statement below ,
SELECT
serial_no,host_name,chasis_model,chasis_flash_size,chasis_dram_size,...
|
by: Opa |
last post by:
Hi,
I have a DataGrid, whose sourceI am exporting to Excel. This works fine
except for the Column ordering. My datasource is not a datatable, with a
typical
SELECT statement where I can...
|
by: pedalpete |
last post by:
I seem to have a few duplicates entries in a very large database.
My database has two identical tables. One is written to on a regular basis (every few seconds) and the other is used for queries,...
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
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: 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,...
| |