I have an array of data get from the server(ordered by date):
[ {date:"2012-8", name:"Tokyo"}, {date:"2012-3", name:"Beijing"}, {date:"2011-10", name:"New York"} ]
I'd like to :
- get the name of the first element whose date is in a given year, for example, given
2012, I needTokyo - get the year of a given
name - change the date of a
name
which data structure should I use to make this effective ?
because the array could be large, I prefer not to loop the array to find something