1000 is more than 200

Started by tac2mike on 4 May 2011, 6:12 PM · Views: 4,193

Results 1 to 20 of 22
4 May 2011, 6:12 PM
#1
tac2mike avatar

tac2mike

New Zenner

Join Date:
Jan 2008
Posts:
12
Plugin Contributions:
0

1000 is more than 200

Can someone please teach my Zencart list of products that a series product with 200 in the name should come before a product with 1000 in it's name? This is real annoying. I don't want to and shouldn't have to go back through and set sort orders to make this happen. As soon as Zencart sees a 1, it puts it before anything else. :censored:

4 May 2011, 6:59 PM
#2
gjh42 avatar

gjh42

Black Belt

Join Date:
Jul 2005
Location:
Upstate NY
Posts:
21,874
Plugin Contributions:
8

Re: 1000 is more than 200

To a human brain, it seems stupidly simple... but there are many ways that numbers could appear in product names, and parsing the name to single out embedded undefined multi-digit numbers, remember them and sort them in relation to other similar names would exponentially increase the processing time for the sort.
You can add zeros to fill out the maximum number of digits, and it might work to add spaces, non-breaking spaces, or some other character similarly. There is a PHP "natural sort" function that sorts numbers in string format as humans would see them, but I don't know if it would still work on mixed alphameric content.

4 May 2011, 7:04 PM
#3
kuroi avatar

kuroi

Totally Zenned

Join Date:
Apr 2006
Location:
London, UK
Posts:
10,475
Plugin Contributions:
11

Re: 1000 is more than 200

Product names are alphanumeric strings and when sorted alphabetically 1 comes before 2, irrespective of the number of zeros that follow.

However, Zen Cart does have a product sort order field for each product that is used in some places to allow site owners to override the normal ordering.

Kuroi Web Design and Development | Twitter

(Questions answered in the forum only - so that any forum member can benefit - not by personal message)

15 Apr 2012, 6:39 PM
#4
rickobee avatar

rickobee

New Zenner

Join Date:
Apr 2012
Posts:
9
Plugin Contributions:
0

Re: 1000 is more than 200

This s a big problem for me as well. I know this thread is a year old but it seemed a good place to add this question:

Is it possible to manually sort only a group of products?

In my case I sell comics which, of course, have issue numbers. But not all of my products need sorting (where issue numbers don't go past #9, for example).

I'm guessing the answer is 'no' as I couldn't find any good solution in the forums. But I had to ask. It just seems so silly that default ordering ends up looking like this:

Super Fun Comics #1
Super Fun Comics #10
Super Fun Comics #17
Super Fun Comics #2
Super Fun Comics #23
Super Fun Comics #3
Super Fun Comics #36

Thanks in advance!

15 Apr 2012, 8:58 PM
#5
schoolboy avatar

schoolboy

Totally Zenned

Join Date:
Jun 2005
Location:
Cumbria, UK
Posts:
10,327
Plugin Contributions:
0

Re: 1000 is more than 200

As kuroi has pointed out, when digits are listed in an alpha-numeric string, they are regarded as TEXT, not numerical values.

This is true in ANY computer program - not just zencart.

The only way to force a desired sort order is to use the sort ordering system in zencart.

We had a project a couple of years ago where over 10,000 products, in over 400 categories/sub-categories needed specialist sorting.

It took a while, but we used Easy Populate to help us, where we brought the EP file into MS Excel, and using MS Excel formulae and data sort features, we were able to insert the desired ZC sort order values in a few hours - rather than the weeks it would have taken to do it product-by-product in ZC.

20 years a Zencart User

15 Apr 2012, 10:45 PM
#6
rickobee avatar

rickobee

New Zenner

Join Date:
Apr 2012
Posts:
9
Plugin Contributions:
0

Re: 1000 is more than 200

schoolboy:

As kuroi has pointed out, when digits are listed in an alpha-numeric string, they are regarded as TEXT, not numerical values.

This is true in ANY computer program - not just zencart.

Well, I can grasp the concept, I just have trouble accepting it! When I access my files in Windows they're ordered as I'd expect. Super Fun Comics #2 comes before Super Fun Comics #10, for example.

I don't doubt what you're saying and I'm not trying to put down Zen Cart (which I like a lot), just saying the default sorting isn't what I'd expect.

Anyhow, as I mentioned, I was hoping there might be a way to manually sort a small group (a particular comic series, for example). A workaround, a mod, a secret trick!

Thanks for the suggestion, I appreciate it. I was really hoping for something a bit simpler...

16 Apr 2012, 6:14 AM
#7
rodg avatar

rodg

Deceased

Join Date:
Jan 2007
Location:
Australia
Posts:
6,263
Plugin Contributions:
4

Re: 1000 is more than 200

rickobee:

Anyhow, as I mentioned, I was hoping there might be a way to manually sort a small group (a particular comic series, for example). A workaround, a mod, a secret trick!

Thanks for the suggestion, I appreciate it. I was really hoping for something a bit simpler...

There IS a 'simple trick' that you can use:

Instead of using descriptions like:

Super Fun Comics #1
Super Fun Comics #10
Super Fun Comics #17
Super Fun Comics #2
Super Fun Comics #23
Super Fun Comics #3
Super Fun Comics #36

You'll need to 'pad' the 'numeric' strings out with zeros, like:

Super Fun Comics #01
Super Fun Comics #10
Super Fun Comics #17
Super Fun Comics #02
Super Fun Comics #23
Super Fun Comics #03
Super Fun Comics #36

This will then cause the sorted display to show as:
Super Fun Comics #01
Super Fun Comics #02
Super Fun Comics #03
Super Fun Comics #10
Super Fun Comics #17
Super Fun Comics #23
Super Fun Comics #36

Needless to say, if there are more than 99 Comics you'll need to use three digit numbers, such as:

Super Fun Comics #001
Super Fun Comics #002
Super Fun Comics #003
Super Fun Comics #010
Super Fun Comics #017
Super Fun Comics #023
Super Fun Comics #036
Super Fun Comics #150
Super Fun Comics #300
etc, etc.

As mentioned, this isn't a zencart issue, and in spite of your statement that "When I access my files in Windows they're ordered as I'd expect" it is a universal issue that is not limited to any given operating system. It is an issue that goes back the the very core of computing because numbers are always lower in the ASCII tables than strings, so 1000 represented as a string "1000" is always going to appear before the number 200 represented as a string value of "200".

If a system does ever display a sorted set of strings such as
Super Fun Comics #1
Super Fun Comics #10
Super Fun Comics #17
Super Fun Comics #2
Super Fun Comics #23
Super Fun Comics #3
Super Fun Comics #36

in the 'correct' order of:
Super Fun Comics #1
Super Fun Comics #2
Super Fun Comics #3
Super Fun Comics #10
Super Fun Comics #17
Super Fun Comics #23
Super Fun Comics #36

It is actually done splitting the strings into their different 'elements' and performing a sort on each element. IOW, it'll first sort all of the "Super", then all the 'Fun", following by the "Comics", and finally by the numeric equivalent of the number strings. All things considered, this adds up to a lot of CPU power for such a simple requirement. Most coders would never go to this extent with a sort routine unless there is a real proven need for it. It'd be easier to separate the string component and the numeric components in the first place.

Important thing to note is that the TEXT STRING "1" is NOT the same as the NUMBER "1", and to take this one step further, you could also have a graphic picture that shows a "1", and needless to say, even though this "1" will look the same as the text and numeric '1's this won't work correctly in a sort function either.

Hopefully this explanation goes a little way to helping you accept the situation, as well as grasp it. :)

Cheers
Rod

NOTE: We are sorry that Rod is no longer with us.
We are grateful for all his contributions to the Zen Cart community.

Ozpost - The Ultimate Shipping module for Australian Merchants. Click these links for its Homepage, or Download from Zen-Cart.com.

16 Apr 2012, 4:46 PM
#8
rickobee avatar

rickobee

New Zenner

Join Date:
Apr 2012
Posts:
9
Plugin Contributions:
0

Re: 1000 is more than 200

Haha, well, I suppose I have no choice but to accept it! Thanks for your informative explanation, Rod.

It is actually done splitting the strings into their different 'elements' and performing a sort on each element. IOW, it'll first sort all of the "Super", then all the 'Fun", following by the "Comics", and finally by the numeric equivalent of the number strings.

Now that's what I'm talking about! At least I know it can be done, eh?

I wonder if an add-on could be built (or a core improvement) that could simply add an extra field to the title for numbers? If the field was populated it'd be added to the end of the title (and would be the secondary sorting criteria). Of course, I have no idea how to construct such a thing but one can dream.

In the meantime I suppose I'll have to break down and add the extra zeroes to the issue numbers. Thanks again!

17 Apr 2012, 1:52 AM
#10
rickobee avatar

rickobee

New Zenner

Join Date:
Apr 2012
Posts:
9
Plugin Contributions:
0

Re: 1000 is more than 200

Well, because I've already got 2000+ products added (I'd assumed the sorting thing would be an easy fix) and don't really want to edit them one by one. And that feature just seems more trouble than it'd be worth since I've got a constantly rotating stock...

I don't think that option had actually come up in this thread though so thanks for mentioning it!

17 Apr 2012, 2:01 AM
#11
gjh42 avatar

gjh42

Black Belt

Join Date:
Jul 2005
Location:
Upstate NY
Posts:
21,874
Plugin Contributions:
8

Re: 1000 is more than 200

From post 3: > ... However, Zen Cart does have a product sort order field for each product that is used in some places to allow site owners to override the normal ordering.
Not that it seems practical for your particular situation...

17 Apr 2012, 7:56 AM
#12
rodg avatar

rodg

Deceased

Join Date:
Jan 2007
Location:
Australia
Posts:
6,263
Plugin Contributions:
4

Re: 1000 is more than 200

rickobee:

I wonder if an add-on could be built (or a core improvement) that could simply add an extra field to the title for numbers?

There is no technical reason why either of these can't be done.

The hard part is finding someone with enough interest (or incentive) to do it.

Cheers
Rod

NOTE: We are sorry that Rod is no longer with us.
We are grateful for all his contributions to the Zen Cart community.

Ozpost - The Ultimate Shipping module for Australian Merchants. Click these links for its Homepage, or Download from Zen-Cart.com.

17 Apr 2012, 11:16 AM
#13
schoolboy avatar

schoolboy

Totally Zenned

Join Date:
Jun 2005
Location:
Cumbria, UK
Posts:
10,327
Plugin Contributions:
0

Re: 1000 is more than 200

I wonder if an add-on could be built (or a core improvement) that could simply add an extra field to the title for numbers? If the field was populated it'd be added to the end of the title (and would be the secondary sorting criteria). Of course, I have no idea how to construct such a thing but one can dream.

No logic in this... The user STILL has to put in what amounts to a sort order. Why put in a function that is ALREADY there? It's like putting a second engine into a car, and running both at the same time... :wacko:

20 years a Zencart User

17 Apr 2012, 12:53 PM
#14
gjh42 avatar

gjh42

Black Belt

Join Date:
Jul 2005
Location:
Upstate NY
Posts:
21,874
Plugin Contributions:
8

Re: 1000 is more than 200

Come to think of it, the sort orders probably could be effectively used for your case, provided each title is in its own category. For Comic A #1 you would enter a sort order of 1, and for Comic A #23 you would enter sort order 23. As long as only Comic A is in the category, there will never be confusion in display or thought required in product entry. It would probably be possible to semi-automate converting your current products exported to a spreadsheet, as mentioned by schoolboy.

17 Apr 2012, 1:22 PM
#15
rodg avatar

rodg

Deceased

Join Date:
Jan 2007
Location:
Australia
Posts:
6,263
Plugin Contributions:
4

Re: 1000 is more than 200

schoolboy:

No logic in this... The user STILL has to put in what amounts to a sort order. Why put in a function that is ALREADY there? It's like putting a second engine into a car, and running both at the same time... :wacko:

Don't some hybrids do this? An Electric engine for the drive with a petrol engine to charge the batteries?

Perhaps there is logic to it after all :P

Cheers
Rod

NOTE: We are sorry that Rod is no longer with us.
We are grateful for all his contributions to the Zen Cart community.

Ozpost - The Ultimate Shipping module for Australian Merchants. Click these links for its Homepage, or Download from Zen-Cart.com.

17 Apr 2012, 5:56 PM
#16
rickobee avatar

rickobee

New Zenner

Join Date:
Apr 2012
Posts:
9
Plugin Contributions:
0

Re: 1000 is more than 200

schoolboy:

No logic in this... The user STILL has to put in what amounts to a sort order. Why put in a function that is ALREADY there?

In my case the limitations of the numerical sorting only impact about a third of my products. I'm already adding an issue number to most products but it would save me from having to also add a sort number to every product. The issue number and sort number would be one and the same.

My thinking is that this add-on/improvement would only kick in for products for which that extra field is populated. So every entry with "Super Fun Comics" as a title would sort itself by the number field and wouldn't impact the rest of the products.

Also, it seems to me the built-in sort feature is most useful for a product line that's fairly static (or for stores with a small number of products). Mine isn't, which means I have to be clever and space the sort numbers by 5s or 10s and then when I add a new listing I have to check the place where it goes to figure out what the sort number will be. Seems like more trouble/time than it's worth. If I'm mistaken about how it works then somebody please let me know.

17 Apr 2012, 6:00 PM
#17
rickobee avatar

rickobee

New Zenner

Join Date:
Apr 2012
Posts:
9
Plugin Contributions:
0

Re: 1000 is more than 200

gjh42:

Come to think of it, the sort orders probably could be effectively used for your case, provided each title is in its own category. For Comic A #1 you would enter a sort order of 1, and for Comic A #23 you would enter sort order 23. As long as only Comic A is in the category, there will never be confusion in display or thought required in product entry.

Is the sort order separate for each category?

If so, that's an interesting thought. I think the problem is that it would mean way too many categories (I actually only use a handful).

17 Apr 2012, 11:14 PM
#18
gjh42 avatar

gjh42

Black Belt

Join Date:
Jul 2005
Location:
Upstate NY
Posts:
21,874
Plugin Contributions:
8

Re: 1000 is more than 200

The sort order is a property of the product. If it is linked to multiple categories, it would appear the same in all of them. This could obviously be an issue if you have different product lines combined in one category. How many different titles do you have (more or less)? How many issues of one title do you typically have in stock?

Since the same issue would always get the same sort order, you wouldn't need to keep track of which one sold etc. If you had two of one issue, they would have the same sort order and would appear one after the other.
If you need to keep different titles in one category, you might assign Title A a sort prefix of 10 and Title B a sort prefix of 20, giving sort orders like 10001, 10033, 10234, 20005, 20789, etc. This is probably getting too much more complex than just adding leading zeros to the issue number in the product name.

25 Apr 2012, 7:41 PM
#19
rickobee avatar

rickobee

New Zenner

Join Date:
Apr 2012
Posts:
9
Plugin Contributions:
0

Re: 1000 is more than 200

Sorry for being so slow to reply, Glenn. I think you're right, that would be getting a bit more complicated than I want to deal with. I appreciate the effort though, and thanks for the info!

25 Apr 2012, 11:23 PM
#20
torvista avatar

torvista

Totally Zenned

Join Date:
Aug 2007
Location:
Gijón, Asturias, Spain
Posts:
2,878
Plugin Contributions:
7

Re: 1000 is more than 200

I had a similar problem recently and came to the conclusion that to minimise the long-term maintenance time, the most efficient way was to pad the numbers with leading zeros as per post#7 and let things work naturally forevermore. Its no great hassle to export (I use Apsona) to a spreadsheet, do the updating and import again. Once it's done it's done and you can forget about it.

Steve
github.com/torvista: BackupMySQL, Structured Data, Multiple Copy-Move-Delete, Google reCaptcha, Image Checker, Spanish Language Pack and more...