Sort by value in multidimensional array The 2019 Stack Overflow Developer Survey Results Are In Announcing the arrival of Valued Associate #679: Cesar Manara Planned maintenance scheduled April 17/18, 2019 at 00:00UTC (8:00pm US/Eastern)Searching multidimensional arraysMulticriteria sort arrayCount array inversions merge sortCreate a struct to store student data and perform statistical analysis on dataAdd values to a multidimensional array of unknown depthConvert “spreadsheet” (flat) data into nested JSON string in PHPgroupArray() - Convert flat array into multidimensional array by groupSort multidimensional array based of the difference in the valueSort multidimensional array based on another one containg the desired orderSort int array by frequency then value
Is every episode of "Where are my Pants?" identical?
Homework question about an engine pulling a train
Free operad over a monoid object
Why doesn't shell automatically fix "useless use of cat"?
Could an empire control the whole planet with today's comunication methods?
How do you keep chess fun when your opponent constantly beats you?
Is 'stolen' appropriate word?
Identify 80s or 90s comics with ripped creatures (not dwarves)
different output for groups and groups USERNAME after adding a username to a group
Why can I use a list index as an indexing variable in a for loop?
Is it ok to offer lower paid work as a trial period before negotiating for a full-time job?
How did passengers keep warm on sail ships?
Can withdrawing asylum be illegal?
ELI5: Why do they say that Israel would have been the fourth country to land a spacecraft on the Moon and why do they call it low cost?
Is this wall load bearing? Blueprints and photos attached
Deal with toxic manager when you can't quit
Drawing vertical/oblique lines in Metrical tree (tikz-qtree, tipa)
Does Parliament hold absolute power in the UK?
Word for: a synonym with a positive connotation?
What do I do when my TA workload is more than expected?
number sequence puzzle deep six
Categorical vs continuous feature selection/engineering
What does Linus Torvalds mean when he says that Git "never ever" tracks a file?
Can I visit the Trinity College (Cambridge) library and see some of their rare books
Sort by value in multidimensional array
The 2019 Stack Overflow Developer Survey Results Are In
Announcing the arrival of Valued Associate #679: Cesar Manara
Planned maintenance scheduled April 17/18, 2019 at 00:00UTC (8:00pm US/Eastern)Searching multidimensional arraysMulticriteria sort arrayCount array inversions merge sortCreate a struct to store student data and perform statistical analysis on dataAdd values to a multidimensional array of unknown depthConvert “spreadsheet” (flat) data into nested JSON string in PHPgroupArray() - Convert flat array into multidimensional array by groupSort multidimensional array based of the difference in the valueSort multidimensional array based on another one containg the desired orderSort int array by frequency then value
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;
$begingroup$
I have a multidimensional array of house properties:
$array = array(
array('apn' => 345345353, 'sqft' => 1121, 'address' => '12 Lincoln Ave.'),
array('apn' => 345345351, 'sqft' => 1643, 'address' => '13 Lincoln Ave.'),
array('apn' => 345345352, 'sqft' => 1222, 'address' => '14 Lincoln Ave.')
array('apn' => 345345358, 'sqft' => 1226, 'address' => '6 Olark Ave.')
array('apn' => 345345345, 'sqft' => 1200, 'address' => '323 Pacific Ave.'),
array('apn' => 345345342, 'sqft' => 1421, 'address' => '324 Pacific Ave.'),
array('apn' => 345345347, 'sqft' => 1093, 'address' => '328 Pacific Ave.'),
);
What I want to create from it is an array with just the lowest and highest address for each street. If a street has only one address then it shouldn't show up in the array.
array('323 Pacific Ave.', '328 Pacific Ave.', '12 Lincoln Ave.', '14 Lincoln Ave.')
Currently I have the following function that works find but it is very verbose and I'm trying to figure out a simple way to sort by value in a multidimensional array.
function minMaxAddress($data)
$addressRanges = array();
$streets = array();
$numProperties = count($data);
$i = 0;
foreach ($data as $key => $listing)
$address = $listing['address'];
$street = getStreetName($address);
if ($i == 0)
$addressRanges[] = $address;
else if ($street != end($streets))
$addressRanges[] = $lastAddress;
$addressRanges[] = $address;
if ($i == $numProperties - 1)
$addressRanges[] = $address;
$streets[] = $street;
$lastAddress = $address;
$i++;
$addressRanges = array_diff($addressRanges, array_diff_assoc($addressRanges, array_unique($addressRanges)));
$addressRanges = array_values($addressRanges);
return $addressRanges;
php array sorting
$endgroup$
migrated from stackoverflow.com May 23 '14 at 18:13
This question came from our site for professional and enthusiast programmers.
add a comment |
$begingroup$
I have a multidimensional array of house properties:
$array = array(
array('apn' => 345345353, 'sqft' => 1121, 'address' => '12 Lincoln Ave.'),
array('apn' => 345345351, 'sqft' => 1643, 'address' => '13 Lincoln Ave.'),
array('apn' => 345345352, 'sqft' => 1222, 'address' => '14 Lincoln Ave.')
array('apn' => 345345358, 'sqft' => 1226, 'address' => '6 Olark Ave.')
array('apn' => 345345345, 'sqft' => 1200, 'address' => '323 Pacific Ave.'),
array('apn' => 345345342, 'sqft' => 1421, 'address' => '324 Pacific Ave.'),
array('apn' => 345345347, 'sqft' => 1093, 'address' => '328 Pacific Ave.'),
);
What I want to create from it is an array with just the lowest and highest address for each street. If a street has only one address then it shouldn't show up in the array.
array('323 Pacific Ave.', '328 Pacific Ave.', '12 Lincoln Ave.', '14 Lincoln Ave.')
Currently I have the following function that works find but it is very verbose and I'm trying to figure out a simple way to sort by value in a multidimensional array.
function minMaxAddress($data)
$addressRanges = array();
$streets = array();
$numProperties = count($data);
$i = 0;
foreach ($data as $key => $listing)
$address = $listing['address'];
$street = getStreetName($address);
if ($i == 0)
$addressRanges[] = $address;
else if ($street != end($streets))
$addressRanges[] = $lastAddress;
$addressRanges[] = $address;
if ($i == $numProperties - 1)
$addressRanges[] = $address;
$streets[] = $street;
$lastAddress = $address;
$i++;
$addressRanges = array_diff($addressRanges, array_diff_assoc($addressRanges, array_unique($addressRanges)));
$addressRanges = array_values($addressRanges);
return $addressRanges;
php array sorting
$endgroup$
migrated from stackoverflow.com May 23 '14 at 18:13
This question came from our site for professional and enthusiast programmers.
1
$begingroup$
I can see the need to sort here, but considering that you have to group by street name first there's no need to sort any multidimensional array. Just break up the original into arrays of street numbers and process each one individually.
$endgroup$
– Jon
May 21 '14 at 21:55
add a comment |
$begingroup$
I have a multidimensional array of house properties:
$array = array(
array('apn' => 345345353, 'sqft' => 1121, 'address' => '12 Lincoln Ave.'),
array('apn' => 345345351, 'sqft' => 1643, 'address' => '13 Lincoln Ave.'),
array('apn' => 345345352, 'sqft' => 1222, 'address' => '14 Lincoln Ave.')
array('apn' => 345345358, 'sqft' => 1226, 'address' => '6 Olark Ave.')
array('apn' => 345345345, 'sqft' => 1200, 'address' => '323 Pacific Ave.'),
array('apn' => 345345342, 'sqft' => 1421, 'address' => '324 Pacific Ave.'),
array('apn' => 345345347, 'sqft' => 1093, 'address' => '328 Pacific Ave.'),
);
What I want to create from it is an array with just the lowest and highest address for each street. If a street has only one address then it shouldn't show up in the array.
array('323 Pacific Ave.', '328 Pacific Ave.', '12 Lincoln Ave.', '14 Lincoln Ave.')
Currently I have the following function that works find but it is very verbose and I'm trying to figure out a simple way to sort by value in a multidimensional array.
function minMaxAddress($data)
$addressRanges = array();
$streets = array();
$numProperties = count($data);
$i = 0;
foreach ($data as $key => $listing)
$address = $listing['address'];
$street = getStreetName($address);
if ($i == 0)
$addressRanges[] = $address;
else if ($street != end($streets))
$addressRanges[] = $lastAddress;
$addressRanges[] = $address;
if ($i == $numProperties - 1)
$addressRanges[] = $address;
$streets[] = $street;
$lastAddress = $address;
$i++;
$addressRanges = array_diff($addressRanges, array_diff_assoc($addressRanges, array_unique($addressRanges)));
$addressRanges = array_values($addressRanges);
return $addressRanges;
php array sorting
$endgroup$
I have a multidimensional array of house properties:
$array = array(
array('apn' => 345345353, 'sqft' => 1121, 'address' => '12 Lincoln Ave.'),
array('apn' => 345345351, 'sqft' => 1643, 'address' => '13 Lincoln Ave.'),
array('apn' => 345345352, 'sqft' => 1222, 'address' => '14 Lincoln Ave.')
array('apn' => 345345358, 'sqft' => 1226, 'address' => '6 Olark Ave.')
array('apn' => 345345345, 'sqft' => 1200, 'address' => '323 Pacific Ave.'),
array('apn' => 345345342, 'sqft' => 1421, 'address' => '324 Pacific Ave.'),
array('apn' => 345345347, 'sqft' => 1093, 'address' => '328 Pacific Ave.'),
);
What I want to create from it is an array with just the lowest and highest address for each street. If a street has only one address then it shouldn't show up in the array.
array('323 Pacific Ave.', '328 Pacific Ave.', '12 Lincoln Ave.', '14 Lincoln Ave.')
Currently I have the following function that works find but it is very verbose and I'm trying to figure out a simple way to sort by value in a multidimensional array.
function minMaxAddress($data)
$addressRanges = array();
$streets = array();
$numProperties = count($data);
$i = 0;
foreach ($data as $key => $listing)
$address = $listing['address'];
$street = getStreetName($address);
if ($i == 0)
$addressRanges[] = $address;
else if ($street != end($streets))
$addressRanges[] = $lastAddress;
$addressRanges[] = $address;
if ($i == $numProperties - 1)
$addressRanges[] = $address;
$streets[] = $street;
$lastAddress = $address;
$i++;
$addressRanges = array_diff($addressRanges, array_diff_assoc($addressRanges, array_unique($addressRanges)));
$addressRanges = array_values($addressRanges);
return $addressRanges;
php array sorting
php array sorting
edited May 23 '14 at 18:32
Ben A. Noone
29219
29219
asked May 21 '14 at 21:51
Ben Davidow
migrated from stackoverflow.com May 23 '14 at 18:13
This question came from our site for professional and enthusiast programmers.
migrated from stackoverflow.com May 23 '14 at 18:13
This question came from our site for professional and enthusiast programmers.
1
$begingroup$
I can see the need to sort here, but considering that you have to group by street name first there's no need to sort any multidimensional array. Just break up the original into arrays of street numbers and process each one individually.
$endgroup$
– Jon
May 21 '14 at 21:55
add a comment |
1
$begingroup$
I can see the need to sort here, but considering that you have to group by street name first there's no need to sort any multidimensional array. Just break up the original into arrays of street numbers and process each one individually.
$endgroup$
– Jon
May 21 '14 at 21:55
1
1
$begingroup$
I can see the need to sort here, but considering that you have to group by street name first there's no need to sort any multidimensional array. Just break up the original into arrays of street numbers and process each one individually.
$endgroup$
– Jon
May 21 '14 at 21:55
$begingroup$
I can see the need to sort here, but considering that you have to group by street name first there's no need to sort any multidimensional array. Just break up the original into arrays of street numbers and process each one individually.
$endgroup$
– Jon
May 21 '14 at 21:55
add a comment |
1 Answer
1
active
oldest
votes
$begingroup$
While this task can be written as a single loop over your data, it would involve unnecessarily convoluted conditionals and temporary variables which will likely be an irritation to future developers (that person might actually be you) that may need to read your code.
I respect your desire to keep things terse, but great code isn't just brief, it is easily comprehensible. I feel that two loops will be the smartest approach. In the first loop, create a grouping array with the street name as keys and push each number into its respective street's subarray.
Then filter the group array for qualifying data (2 or more numbers in a group), extract the highest and lowest number, then append the bookend numbers to the street name.
Code: (Demo)
$array = [
['apn' => 345345353, 'sqft' => 1121, 'address' => '12 Lincoln Ave.'],
['apn' => 345345351, 'sqft' => 1643, 'address' => '13 Lincoln Ave.'],
['apn' => 345345352, 'sqft' => 1222, 'address' => '14 Lincoln Ave.'],
['apn' => 345345358, 'sqft' => 1226, 'address' => '6 Olark Ave.'],
['apn' => 345345345, 'sqft' => 1200, 'address' => '323 Pacific Ave.'],
['apn' => 345345342, 'sqft' => 1421, 'address' => '324 Pacific Ave.'],
['apn' => 345345347, 'sqft' => 1093, 'address' => '328 Pacific Ave.'],
];
foreach ($array as $row)
[$number, $street] = explode(' ', $row['address'], 2);
$group[$street][] = $number;
$result = [];
foreach ($group as $street => $numbers)
if (sizeof($numbers) > 1)
array_push($result, min($numbers) . ' ' . $street, max($numbers) . ' ' . $street);
var_export($result);
Output:
array (
0 => '12 Lincoln Ave.',
1 => '14 Lincoln Ave.',
2 => '323 Pacific Ave.',
3 => '328 Pacific Ave.',
)
$endgroup$
add a comment |
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "196"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
var $window = $(window),
onScroll = function(e)
var $elem = $('.new-login-left'),
docViewTop = $window.scrollTop(),
docViewBottom = docViewTop + $window.height(),
elemTop = $elem.offset().top,
elemBottom = elemTop + $elem.height();
if ((docViewTop elemBottom))
StackExchange.using('gps', function() StackExchange.gps.track('embedded_signup_form.view', location: 'question_page' ); );
$window.unbind('scroll', onScroll);
;
$window.on('scroll', onScroll);
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fcodereview.stackexchange.com%2fquestions%2f51564%2fsort-by-value-in-multidimensional-array%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
$begingroup$
While this task can be written as a single loop over your data, it would involve unnecessarily convoluted conditionals and temporary variables which will likely be an irritation to future developers (that person might actually be you) that may need to read your code.
I respect your desire to keep things terse, but great code isn't just brief, it is easily comprehensible. I feel that two loops will be the smartest approach. In the first loop, create a grouping array with the street name as keys and push each number into its respective street's subarray.
Then filter the group array for qualifying data (2 or more numbers in a group), extract the highest and lowest number, then append the bookend numbers to the street name.
Code: (Demo)
$array = [
['apn' => 345345353, 'sqft' => 1121, 'address' => '12 Lincoln Ave.'],
['apn' => 345345351, 'sqft' => 1643, 'address' => '13 Lincoln Ave.'],
['apn' => 345345352, 'sqft' => 1222, 'address' => '14 Lincoln Ave.'],
['apn' => 345345358, 'sqft' => 1226, 'address' => '6 Olark Ave.'],
['apn' => 345345345, 'sqft' => 1200, 'address' => '323 Pacific Ave.'],
['apn' => 345345342, 'sqft' => 1421, 'address' => '324 Pacific Ave.'],
['apn' => 345345347, 'sqft' => 1093, 'address' => '328 Pacific Ave.'],
];
foreach ($array as $row)
[$number, $street] = explode(' ', $row['address'], 2);
$group[$street][] = $number;
$result = [];
foreach ($group as $street => $numbers)
if (sizeof($numbers) > 1)
array_push($result, min($numbers) . ' ' . $street, max($numbers) . ' ' . $street);
var_export($result);
Output:
array (
0 => '12 Lincoln Ave.',
1 => '14 Lincoln Ave.',
2 => '323 Pacific Ave.',
3 => '328 Pacific Ave.',
)
$endgroup$
add a comment |
$begingroup$
While this task can be written as a single loop over your data, it would involve unnecessarily convoluted conditionals and temporary variables which will likely be an irritation to future developers (that person might actually be you) that may need to read your code.
I respect your desire to keep things terse, but great code isn't just brief, it is easily comprehensible. I feel that two loops will be the smartest approach. In the first loop, create a grouping array with the street name as keys and push each number into its respective street's subarray.
Then filter the group array for qualifying data (2 or more numbers in a group), extract the highest and lowest number, then append the bookend numbers to the street name.
Code: (Demo)
$array = [
['apn' => 345345353, 'sqft' => 1121, 'address' => '12 Lincoln Ave.'],
['apn' => 345345351, 'sqft' => 1643, 'address' => '13 Lincoln Ave.'],
['apn' => 345345352, 'sqft' => 1222, 'address' => '14 Lincoln Ave.'],
['apn' => 345345358, 'sqft' => 1226, 'address' => '6 Olark Ave.'],
['apn' => 345345345, 'sqft' => 1200, 'address' => '323 Pacific Ave.'],
['apn' => 345345342, 'sqft' => 1421, 'address' => '324 Pacific Ave.'],
['apn' => 345345347, 'sqft' => 1093, 'address' => '328 Pacific Ave.'],
];
foreach ($array as $row)
[$number, $street] = explode(' ', $row['address'], 2);
$group[$street][] = $number;
$result = [];
foreach ($group as $street => $numbers)
if (sizeof($numbers) > 1)
array_push($result, min($numbers) . ' ' . $street, max($numbers) . ' ' . $street);
var_export($result);
Output:
array (
0 => '12 Lincoln Ave.',
1 => '14 Lincoln Ave.',
2 => '323 Pacific Ave.',
3 => '328 Pacific Ave.',
)
$endgroup$
add a comment |
$begingroup$
While this task can be written as a single loop over your data, it would involve unnecessarily convoluted conditionals and temporary variables which will likely be an irritation to future developers (that person might actually be you) that may need to read your code.
I respect your desire to keep things terse, but great code isn't just brief, it is easily comprehensible. I feel that two loops will be the smartest approach. In the first loop, create a grouping array with the street name as keys and push each number into its respective street's subarray.
Then filter the group array for qualifying data (2 or more numbers in a group), extract the highest and lowest number, then append the bookend numbers to the street name.
Code: (Demo)
$array = [
['apn' => 345345353, 'sqft' => 1121, 'address' => '12 Lincoln Ave.'],
['apn' => 345345351, 'sqft' => 1643, 'address' => '13 Lincoln Ave.'],
['apn' => 345345352, 'sqft' => 1222, 'address' => '14 Lincoln Ave.'],
['apn' => 345345358, 'sqft' => 1226, 'address' => '6 Olark Ave.'],
['apn' => 345345345, 'sqft' => 1200, 'address' => '323 Pacific Ave.'],
['apn' => 345345342, 'sqft' => 1421, 'address' => '324 Pacific Ave.'],
['apn' => 345345347, 'sqft' => 1093, 'address' => '328 Pacific Ave.'],
];
foreach ($array as $row)
[$number, $street] = explode(' ', $row['address'], 2);
$group[$street][] = $number;
$result = [];
foreach ($group as $street => $numbers)
if (sizeof($numbers) > 1)
array_push($result, min($numbers) . ' ' . $street, max($numbers) . ' ' . $street);
var_export($result);
Output:
array (
0 => '12 Lincoln Ave.',
1 => '14 Lincoln Ave.',
2 => '323 Pacific Ave.',
3 => '328 Pacific Ave.',
)
$endgroup$
While this task can be written as a single loop over your data, it would involve unnecessarily convoluted conditionals and temporary variables which will likely be an irritation to future developers (that person might actually be you) that may need to read your code.
I respect your desire to keep things terse, but great code isn't just brief, it is easily comprehensible. I feel that two loops will be the smartest approach. In the first loop, create a grouping array with the street name as keys and push each number into its respective street's subarray.
Then filter the group array for qualifying data (2 or more numbers in a group), extract the highest and lowest number, then append the bookend numbers to the street name.
Code: (Demo)
$array = [
['apn' => 345345353, 'sqft' => 1121, 'address' => '12 Lincoln Ave.'],
['apn' => 345345351, 'sqft' => 1643, 'address' => '13 Lincoln Ave.'],
['apn' => 345345352, 'sqft' => 1222, 'address' => '14 Lincoln Ave.'],
['apn' => 345345358, 'sqft' => 1226, 'address' => '6 Olark Ave.'],
['apn' => 345345345, 'sqft' => 1200, 'address' => '323 Pacific Ave.'],
['apn' => 345345342, 'sqft' => 1421, 'address' => '324 Pacific Ave.'],
['apn' => 345345347, 'sqft' => 1093, 'address' => '328 Pacific Ave.'],
];
foreach ($array as $row)
[$number, $street] = explode(' ', $row['address'], 2);
$group[$street][] = $number;
$result = [];
foreach ($group as $street => $numbers)
if (sizeof($numbers) > 1)
array_push($result, min($numbers) . ' ' . $street, max($numbers) . ' ' . $street);
var_export($result);
Output:
array (
0 => '12 Lincoln Ave.',
1 => '14 Lincoln Ave.',
2 => '323 Pacific Ave.',
3 => '328 Pacific Ave.',
)
edited 17 mins ago
answered Sep 18 '17 at 12:31
mickmackusamickmackusa
2,119221
2,119221
add a comment |
add a comment |
Thanks for contributing an answer to Code Review Stack Exchange!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
Use MathJax to format equations. MathJax reference.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
var $window = $(window),
onScroll = function(e)
var $elem = $('.new-login-left'),
docViewTop = $window.scrollTop(),
docViewBottom = docViewTop + $window.height(),
elemTop = $elem.offset().top,
elemBottom = elemTop + $elem.height();
if ((docViewTop elemBottom))
StackExchange.using('gps', function() StackExchange.gps.track('embedded_signup_form.view', location: 'question_page' ); );
$window.unbind('scroll', onScroll);
;
$window.on('scroll', onScroll);
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fcodereview.stackexchange.com%2fquestions%2f51564%2fsort-by-value-in-multidimensional-array%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
var $window = $(window),
onScroll = function(e)
var $elem = $('.new-login-left'),
docViewTop = $window.scrollTop(),
docViewBottom = docViewTop + $window.height(),
elemTop = $elem.offset().top,
elemBottom = elemTop + $elem.height();
if ((docViewTop elemBottom))
StackExchange.using('gps', function() StackExchange.gps.track('embedded_signup_form.view', location: 'question_page' ); );
$window.unbind('scroll', onScroll);
;
$window.on('scroll', onScroll);
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
var $window = $(window),
onScroll = function(e)
var $elem = $('.new-login-left'),
docViewTop = $window.scrollTop(),
docViewBottom = docViewTop + $window.height(),
elemTop = $elem.offset().top,
elemBottom = elemTop + $elem.height();
if ((docViewTop elemBottom))
StackExchange.using('gps', function() StackExchange.gps.track('embedded_signup_form.view', location: 'question_page' ); );
$window.unbind('scroll', onScroll);
;
$window.on('scroll', onScroll);
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
var $window = $(window),
onScroll = function(e)
var $elem = $('.new-login-left'),
docViewTop = $window.scrollTop(),
docViewBottom = docViewTop + $window.height(),
elemTop = $elem.offset().top,
elemBottom = elemTop + $elem.height();
if ((docViewTop elemBottom))
StackExchange.using('gps', function() StackExchange.gps.track('embedded_signup_form.view', location: 'question_page' ); );
$window.unbind('scroll', onScroll);
;
$window.on('scroll', onScroll);
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
1
$begingroup$
I can see the need to sort here, but considering that you have to group by street name first there's no need to sort any multidimensional array. Just break up the original into arrays of street numbers and process each one individually.
$endgroup$
– Jon
May 21 '14 at 21:55