Custom PHP array sorting function for dynamicaly built array
$10-30 USD
V teku
Objavljeno pred približno 5 leti
$10-30 USD
Plačilo ob dostavi
Need help with a custom PHP 5.6 array sorting function. We have a Multidimensional PHP array that looks like below, but the answer sets always change as the array is dynamically built. We would like to sort all items on the "Percent" column but also have any "Label" items that have a "None of these" or "Other" always sort to the bottom. The array column answer sets are dynamic and change so we do not know the label position ahead of time. We do not want to alter the structure of the current array so the label text is the only way to identify it. The array is dynamically built and may have more columns based on the situation but the first three columns will always be the same.
cars = array(
array(Label1, Count1, Percent1)
array(Label2, Count2, Percent2)
etc.
)
OR with real data
$cars = array
(
array("Volvo",22,62),
array("BMW",29,75),
array("Saab",5,2),
array("Land Rover",43,86)
array("Other",31,78)
array("None of these",8,15)
);
Desired sort result
Land Rover,43,86
BMW,29,75
Volvo,22,62
Saab,5,2
Other,31,78
None of these,8,15
Current function looks like this but does not sort the labels to the bottom
function compareCount ($x, $y)
{
if ($x[2] == $y[2])
return 0;
else if ($x[2] > $y[2])
return -1;
else
return 1;
}
Hello
I have 5 year experience in php development and i'm sure i can help you with this. i can start work right now. Please consider me for this job.
Thanks
Dear sir,
I am very interested in this project. I have 8+ Year of Experience in this field and I can surely do this project, I work as freelancer with my inhouse team. Please try to give me one chance to prove my strength and quality of work.
I always believe in quality work and always ready to provide you best solution for your project.
Trust me sir i never disappoint you at least you can give me one chance.
Please check my profile in freelancer.com
https://www.freelancer.com/u/mdubey.html
Please message me on PM for further discussion.
Thanks & Regards
Mohit
Hi i have two year experience in web and app development field. i am new to freelancer but not in technology So please give me a chance to work with your project Thanks.