Comments (6)
What you mean sort? It's not an ordered collection.
Are you referring to the order you get them items when you call forEach()?
If so you could do something like:
map.keys().sort().forEach(function(key) {
var value = map.get(key);
// ...
});
from hashmap.
that'll work... thanks!
from hashmap.
so the sort on keys works well... but... how would you go about sorting on value?
from hashmap.
This?
map.values().sort().forEach(function(value) {
// ...
});
from hashmap.
Right, but then how to retrieve the key? On this example:
joe : 10
alice : 50
paul : 2
phil : 10
I can sort the values and get 50, 10, 10, 2... but then how do i get back to the keys so i can display something like:
alice : 50
joe : 10
phil : 10
paul 2
Thanks!
from hashmap.
Well, for start, there's no point in using using HashMap for string keys. You can use a plain object for that.
At this point, if you wish to continue this way, I'd say you should rather modify hashmap code to suit your needs.
You can solve it by asking for the keys and values and making some sort of external collection but at that point, why would you even be using hashmap.
from hashmap.
Related Issues (20)
- Why does `multi` exist? HOT 2
- Feature Request: forEach break HOT 1
- Export as javascript array with key:pair value HOT 1
- Hashmap breaks when minified HOT 2
- Examples of search function HOT 1
- Remove and clear all not working. HOT 3
- Get the size of the map
- TypeError: HashMap is not a constructor HOT 1
- Uncaught RangeError: Maximum call stack size exceeded
- Add time coplexity of each operation HOT 1
- Wrong behaviour? HOT 5
- The numbering inside "_data" object does not reset HOT 1
- intigrating it into angualr application HOT 1
- Better hashing of keys HOT 1
- Cant install on Linux HOT 2
- Could you elaborate on the runtimes of the operations, basically get, set, multi and has? HOT 4
- Question: object as keys HOT 3
- Not a hashmap HOT 4
- HashMap Support with React Native HOT 3
- Clarify readme
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from hashmap.