Filtering data in an Array

Hi all,

I have an array that has 30 date objects. The date objects are indexed in the array from minimum date value to maximum date value. What I would like to do is retrieve only 7 dates from the array. Out of the 7, the first one should be the minDate and the last should be the maxDate, with 5 dates in the middle. The 7 numbers should increment evenly from the minDate to the maxDate. How would I accomplish this? Hope I was clear.

Thanks,
Tonih
toneDigitalAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Michel PlungjanIT ExpertCommented:
Here is the first and last part

http://javascript.about.com/library/blsort3.htm
0
toneDigitalAuthor Commented:
Thanks mplugjan!

is it possible to show an entire solution? I'm really am not getting this. Would you know how to do this with actionscript?

thanks

0
Michel PlungjanIT ExpertCommented:
1. I do not do actionscript
2. You need some kind of math to find some kind of median values

The link I gave you shows how to sort a date array
0
Michel PlungjanIT ExpertCommented:
Okay - seems you found a solution elsewhere. Please share when you have a complete solution.
Thanks
0
toneDigitalAuthor Commented:
Sorry for very late reply. I found a solution. If there is a better one, please suggest. Thanks.

var midpt = Math.ceil((my_array.length-2)/2);
var apt = Math.floor(midpt/3);
var off = (mid%3);

trace(my_array[0]);
trace(my_array[(off>3) ? apt+1 : apt]);
trace(my_array[(off>1) ? midpt-apt : midpt-apt-1]);
trace(my_array[midpt]);
trace(my_array[(off>0) ? midpt+apt : midpt+apt+1]);
trace(my_array[(off>2) ? my_array.length-1-apt : my_array.length-1-apt-1]);
trace(my_array[my_array.length-1]);
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Adobe Flash

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.