==========================================
I try write code as below, but don’t work, any friend can give help?
Whether “Schwarzian Transform” better for this?
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?
get the lines, sort them by: the last string segment in a comma
separated string, look for digits, and convert them to integers.
I haven’t tested it, and there are probably more elegant ways to do
this, but it should get you moving in the right direction.
Dear Ryan,
Your solution works fine, I understand now, my method is sort one by
one, at last only last sort take effect. Also my method is too
expatiatory and ugly.
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.
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?
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.
Dear Mattel,
I understand now, many thanks for your guide.
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.