分拣服装尺码(XXS XS S M L XL XXL) [英] Sorting Clothing Sizes (XXS XS S M L XL XXL)

查看:243
本文介绍了分拣服装尺码(XXS XS S M L XL XXL)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直试图找到一种合理的方法来按尺寸对服装项目进行排序,但谷歌并没有帮助我。我知道以前必须这样做。我已经看过一个用Python编写的例子,但我不做Python,语法太抽象了,甚至不能坐下来试着把它分开。


最好的东西我能想出来的是:

1.反转字符串

2.对它们进行反转

3.反向订单

4.反转字符串


示例集:S XL M XXS L XXL


//翻转字符串

1. S LX M SXX L LXX


//将它们反向排序

2. L LX LXX MS SX SXX


//撤销订单

3. SXX SX SML LX LXX


//撤销字符串

4. XXS XS SML XL XXL


任何人都可以提出更快/更好的东西吗?

I''ve been trying to find a reasonable way to sort a collection of clothing items by size but google isn''t helping my out very much. I know this has to have been done before. I''ve seen an example written in Python but I don''t do Python and the syntax is far too abstract to even sit and try to pick it apart.

The best thing I''ve been able to come up with is to:
1. Reverse the strings
2. Sort them reversed
3. Reverse the order
4. Reverse the strings

example set: S XL M XXS L XXL

// Reverse the strings
1. S LX M SXX L LXX

// Sort them reversed
2. L LX LXX M S SX SXX

// Reverse the order
3. SXX SX S M L LX LXX

// Reverse the strings
4. XXS XS S M L XL XXL

Can anyone come up with something faster/better?

推荐答案

你只看7件事,为什么不用硬编码值来对它们进行排序?或者甚至为它们分配数字作为键值对并按这种方式排序。
You are only looking at 7 things why don''t you just sort them by hard coding the values? Or even assign numbers to them as a key value pair and sort that way.



你只看7件事为什么不要''你只是通过对值进行硬编码来对它们进行排序吗?或者甚至将数字指定给它们作为键值对并按此方式排序。
You are only looking at 7 things why don''t you just sort them by hard coding the values? Or even assign numbers to them as a key value pair and sort that way.



这只是一个例子。在生产环境中,排序例程需要能够仅基于文本进行排序。没有迹象表明这些将是唯一的值,也没有规则说明尺寸将全部显示为XS,XXS或XL。例如,尺寸可以是XS或XSM。


无论采用何种方案,在整个项目尺寸范围内都会继续遵循。


我希望能够容纳像X-SMALL或XX-SMALL这样的方案,因为我已经在一些较旧的数据中看到了这个方案,但不能保证未来的数据集赢了没有那个方案或任何其他常见的服装尺寸方案。


在某些情况下,我的颜色或其他描述符的大小如XL(黑色)。对于那些情况,我目前在大小和描述符之间拆分字符串并分别处理它对我有意义。

That was just an example. In the production environment the sorting routine needs to be able to sort based on text alone. There is no indication that those will be the only values and also no rule that states the sizes will all ways appear as XS, XXS, or XL. For example, the size may come in as X-S or XSM.

Whatever the scheme, it will continue to be followed throughout the set of item sizes.

I''d like to be able to also accomodate schemes like X-SMALL or XX-SMALL as I''ve seen that scheme in some of the older data, but there is no guarantee that a future data set won''t have that scheme or any other common clothing size scheme.

There are also situations where there my be a color or other descriptor following the size such as XL (Black). For those situations I currently split the string between the size and descriptor and process them separately which makes sense to me.



那只是一个例。在生产环境中,排序例程需要能够仅基于文本进行排序。没有迹象表明这些将是唯一的值,也没有规则说明尺寸将全部显示为XS,XXS或XL。例如,尺寸可以是XS或XSM。


无论采用何种方案,在整个项目尺寸范围内都会继续遵循。


我希望能够容纳像X-SMALL或XX-SMALL这样的方案,因为我已经在一些较旧的数据中看到了这个方案,但不能保证未来的数据集赢了没有那个方案或任何其他常见的服装尺寸方案。


在某些情况下,我的颜色或其他描述符的大小如XL(黑色)。对于那些情况,我目前在大小和描述符之间拆分字符串并单独处理它们对我来说很有意义。
That was just an example. In the production environment the sorting routine needs to be able to sort based on text alone. There is no indication that those will be the only values and also no rule that states the sizes will all ways appear as XS, XXS, or XL. For example, the size may come in as X-S or XSM.

Whatever the scheme, it will continue to be followed throughout the set of item sizes.

I''d like to be able to also accomodate schemes like X-SMALL or XX-SMALL as I''ve seen that scheme in some of the older data, but there is no guarantee that a future data set won''t have that scheme or any other common clothing size scheme.

There are also situations where there my be a color or other descriptor following the size such as XL (Black). For those situations I currently split the string between the size and descriptor and process them separately which makes sense to me.



基于单独的文本排序,这是不可能的。您必须拥有一定数量的令牌或至少一组预定的数据。使你的令牌S M L很好然后你可以很容易地解析XS XXXXXXS和XXXXXXXXXXXS而不需要创建更多的案例来排序,只需将X'转换为数字即可。但是排序S X-Small XSML XBSML SMLXB DUCK CAR BOAT将无法工作。

It''s impossible to do this based on a text sort alone. You must have a set amount of tokens or at least a predetermined set of data. Making your tokens S M L is fine then you can parse the XS XXXXXXS and XXXXXXXXXXXS easy enough with out creating more cases to sort by, just convert the X''s to a number. But sorting S X-Small XSML XBSML SMLXB DUCK CAR BOAT will never work.


这篇关于分拣服装尺码(XXS XS S M L XL XXL)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆