I can't really read this blob, so I'm not sure at to it's point.
You want to "sort by" a subset of the string, numerically, and you already found "sort_by" (which basically IS the schwartzian transform in one beautiful method). So why not do just that?
You want to "sort by" a subset of the string, numerically, and you
already found "sort_by" (which basically IS the schwartzian transform in
one beautiful method). So why not do just that?
On Fri, Jan 24, 2014 at 3:24 PM, Previn Lin <lists@ruby-forum.com> wrote:
Ryan Davis wrote in post #1134243:
You want to "sort by" a subset of the string, numerically, and you
already found "sort_by" (which basically IS the schwartzian transform in
one beautiful method). So why not do just that?
May I ask whether there is any forum thread or document I can reference
and study about the usage and grammar of " line[/start\s+(.*)/,
1]) " you used here? How to do if want grab 2 or 3 brackets?
This is one of the (many) uses of String#
Notably: str[regexp, capture] → new_str or nil
If a Regexp is supplied, the matching portion of the string is returned.
If a capture follows the regular expression, which may be a capture
group index or name, follows the regular expression that component of
the MatchData is returned instead.
May I ask whether there is any forum thread or document I can reference
and study about the usage and grammar of " line[/start\s+(.*)/,
1]) " you used here? How to do if want grab 2 or 3 brackets?
If a Regexp is supplied, the matching portion of the string is returned.
If a capture follows the regular expression, which may be a capture
group index or name, follows the regular expression that component of
the MatchData is returned instead.