Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to get unordered key value pair

The problem is that ; I am retrieving a key value data object pair from database it is like

(select * from xyz ORDER BY letter DESC)

3 z,
2 y,
1 x

And Im putting these to a Long, String HashMap pair. The problem is when I putting these to Map pair, the order is changing. It appears as

1 x,
2 y,
3 z 

How can i preserve data as in first situation.

like image 735
mibzer Avatar asked May 10 '11 11:05

mibzer


1 Answers

Use a LinkedHashMap instead! That will keep the order.

like image 135
Tobias Avatar answered Sep 28 '22 03:09

Tobias